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?
The physical path is 'C:\WINDOWS\TEMP\. net\FreshIQAppMessagingService\zu4jbgzc. let AppDomain.
The InstallUtil binary may also be digitally signed by Microsoft and located in the . NET directories on a Windows system: C:\Windows\Microsoft.NET\Framework\v \InstallUtil.exe and C:\Windows\Microsoft.NET\Framework64\v \InstallUtil.exe .
The installation directory contains files such as executable files and default files that do not change when the system is running. You can change the default installation directory, but for a multiple server installation, use the same installation directory path on all servers.
Generally on a 64 Bit Computer, 32 bit programs are stored in C:\Program Files (x86) However the 64 Bit programs on a 64 Bit computer will be stored in C:\Program Fileswhich is the same as the directory for all 32 Bit computers programs. jd3sp4o0y and 26 more users found this answer helpful. heart outlined.
You can use reflection to get the location of the executing assembly. Here's a simple routine that sets the working directory to the location of the executing assembly using reflection:
String path = System.Reflection.Assembly.GetExecutingAssembly().Location;
path = System.IO.Path.GetDirectoryName(path);
Directory.SetCurrentDirectory(path);
Do you mean you want the directory containing the assembly? If so, that's easy: use Assembly.Location
.
I wouldn't try to change the working directory of the process though - I wouldn't be surprised if that had nasty side effects, if indeed you're allowed to do it.
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