Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Path to the executable of a windows service

How can I get the path to the executable of a specific windows service from another program ? Unfortunately the class ServiceController (System.ServiceProcess) doesn't provide a method or property for that !

like image 628
Kottan Avatar asked Jun 18 '10 16:06

Kottan


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 executable path in Windows services?

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.

What is Windows executable path?

The Windows System PATH tells your PC where it can find specific directories that contain executable files. ipconfig.exe , for example, is found in the C:\Windows\System32 directory, which is a part of the system PATH by default.

What is service path?

servicePath is a configure, price and quote (CPQ) platform that is specifically designed to make complex quotes simple. Quotes that used to take days and involve multiple departments can be done in less than an hour in servicePath.


2 Answers

There's always the WMI class Win32_Service as described here, specifically the PathName.

This works:

ManagementClass mc = new ManagementClass("Win32_Service");
foreach(ManagementObject mo in mc.GetInstances())
{
    if(mo.GetPropertyValue("Name").ToString() == "<Short name of your service>")
    {
        return mo.GetPropertyValue("PathName").ToString().Trim('"');
    }
}
like image 159
Hans Olsson Avatar answered Nov 15 '22 13:11

Hans Olsson


You can obtain them from here using the Registry in HKLM:

 System\CurrentControlSet\Services\Service

Look for the ImagePath value.

like image 45
Brian R. Bondy Avatar answered Nov 15 '22 14:11

Brian R. Bondy