My application (which is a windows service) needs one command line argument which is the location of a config file.
I want the service to be able to start automatically. Filling in the ‘Startup parameters’ value only applies to manually starting it and that value does not carry over after the service is stopped.
I tried manually editing the “Path to executable” in the registry but the .net service doesn’t regocnise it as if it were a command line (taking the 2nd section of the path as the arguments)
Is there a way to setup a default argument on install (either using InstallUtil or any other way)?
Thanks
You can add command line parameters to your service by appending them to the ImagePath parameter value found in :
Using the Environment.GetCommandLineArgs Method you can read them in your service when it gets started.