How do I find the install directory of a Windows Service, using C#?
- by endian
I'm pretty sure that a Windows service gets C:\winnt (or similar) as its working directory when installed using InstallUtil.exe. Is there any way I can access, or otherwise capture (at install time), the directory from which the service was originally installed? At the moment I'm manually entering that into the app.exe.config file, but that's horribly manual and feels like a hack.
Is there a programmatic way, either at run time or install time, to determine where the service was installed from?