Please help - How to get the Path of Executable of a Windows Service...

Dear Experts,

I would like to get the parameter "Path to Executable" of a Windows Service programmatically. As you know, we can use Service MMC snap-in (Control Panel --> Services) to adminstrate Windows Services. If you right click any one of the Windows Services and then choose Properties, you would see the Service snap-in.

In the Service snap-in, there is an item called "Path to Executable" that shows you the original location of your Windows Service's executable. Now I would like to get this path programmatically. Could you please tell me how I can achieve that

Many thanks for your help. :-)

Tigger



Answer this question

Please help - How to get the Path of Executable of a Windows Service...

  • Davegraphix

    In order to do this you must dive into the HKEY_LOCAL_MACHINE bowels of the registry I fear, all the way to:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\service name

    Within the key of your chosen service name you will find a value pair named ImagePath which is associated with the path to the service complete with any related arguments.



  • Vishal Kalra

    You can find the command line used to launch each service in the registry at HKLM/System/CurrentControlSet/Services/<servicename>/ImagePath. Maybe that will get you enough for your purposes.



  • Please help - How to get the Path of Executable of a Windows Service...