We have a Windows Service application that can accept command line parameters like:
MyService -option
So far, when we want to start the
The only thing that worked for me was to add the parameter to the ImagePath on the registry like the following image :
According to the ServiceBase.OnStart documentation:
The arguments entered in the console are not saved; they are passed to the service on a one-time basis when the service is started from the control panel. Arguments that must be present when the service is automatically started can be placed in the ImagePath string value for the service's registry key (HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\). You can obtain the arguments from the registry using the GetCommandLineArgs method, for example: string[] imagePathArgs = Environment.GetCommandLineArgs();.