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 !
A:
Orsol
2010-06-18 16:05:40
A:
You can obtain them from here using the Registry in HKLM:
System\CurrentControlSet\Services\Service
Look for the ImagePath value.
Brian R. Bondy
2010-06-18 16:05:53
A:
There's always the WMI class Win32_Service
as described here, specifically the PathName
.
Something like this might work:
ManagementClass mc = new ManagementClass("Win32_Service");
foreach(ManagementObject mo in mc.GetInstances())
{
if(mo.GetPropertyValue("Name").ToString() = "NameYouWant")
{
return mo.GetPropertyValue("PathName").ToString();
}
}
ho1
2010-06-18 16:11:32