How can I find the location of exe that runs as a windows service in run-time?
Use a registry look-up:
e.g.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\' + ServiceDisplayName;
then read ImagePath value.
Programmatically or with a tool?
In the latter case, I recommend using Sysinternals' Process Explorer: it shows all running processes, including services, and one of the fields is the command line used to run the process, including full path.
Their command line utility, PsService, can be useful too.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With