How do I find the install directory of a Windows Service, using C#?

Posted by endian on Stack Overflow See other posts from Stack Overflow or by endian
Published on 2009-01-29T14:14:07Z Indexed on 2010/05/10 13:54 UTC
Read the original article Hit count: 190

Filed under:
|
|

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?

© Stack Overflow or respective owner

Related posts about c#

Related posts about Windows