Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting full path for Windows Service

How can I find out the folder where the windows service .exe file is installed dynamically?

Path.GetFullPath(relativePath); 

returns a path based on C:\WINDOWS\system32 directory.

However, the XmlDocument.Load(string filename) method appears to be working against relative path inside the directory where the service .exe file is installed to.

like image 608
Samuel Kim Avatar asked Oct 14 '08 03:10

Samuel Kim


People also ask

How do I find the path of a Windows service?

The physical path is 'C:\WINDOWS\TEMP\. net\FreshIQAppMessagingService\zu4jbgzc. let AppDomain.

How do I change the path of a Windows service executable?

To change the executable path of ServiceDesk go to below-mentioned location from registry. run -> regedit -> navigate to the below-mentioned location and highlight the ServiceDesk and from the right-hand side edit the ImagePath as required.

How do I change Windows service parameters?

Click the Start button in the Windows taskbar. In the menu, right-click Command Prompt. On the pop-up right click context menu, select Run as administrator. At the command prompt, enter the SC Config command with the service name to be modified and the parameters to be changed.


2 Answers

Try

System.Reflection.Assembly.GetEntryAssembly().Location 
like image 137
Greg Dean Avatar answered Sep 29 '22 03:09

Greg Dean


Try this:

AppDomain.CurrentDomain.BaseDirectory 

(Just like here: How to find windows service exe path)

like image 26
Curtis Yallop Avatar answered Sep 29 '22 03:09

Curtis Yallop