I try to install a Windows Service having parameters.
I try to reproduce something like this:
but it seem impossible to install it like this :
InstallUtil.exe "C:\MyPath..\MyExe.ProcessorService.exe -service myParam"
I try to install a Windows Service having parameters.
I try to reproduce something like this:
but it seem impossible to install it like this :
InstallUtil.exe "C:\MyPath..\MyExe.ProcessorService.exe -service myParam"
From what I can tell, InstallUtil.exe
does not support this. It doesn't appear to have command line switches for adding parameters to the service start command.
It does appear you can do this via the sc start
command from this answer. The net start
command might even allow you to do it, too, based on this answer.
Fundamentally, if you have a service named Foo
, the registry key of interest is ImagePath
:
[HKLM\SYSTEM\CurrentControlSet\Services\Foo]
"ImagePath":<PathToService>\MyService.exe Parameter1 Parameter2
If you following the instructions here to have your service install itself from the command line (e.g., <PathToService>\MyService.exe -install
), you should be able add the necessary logic after the InstallService()
call to have the service update its ImagePath
registry key with the necessary parameters.
HTH