I am using command line arguments to pass some configuration to the windows service (it will be few instances with different command lines).
My code looks like this:
You can't modify the command line passed to the service. I get around this by saving those parameters to configuration next to the exe. So a user can do this:
service.exe run /sqlserver:connectionstring
and the app saves the connectionstring to a file (either using System.IO.File or using ConfigurationManager)
Then, if the user does this:
service.exe run
Or if the service runs as a windows service, then the app just loads from config.