0

I try to install a Windows Service having parameters.

I try to reproduce something like this:

enter image description here

but it seem impossible to install it like this :

InstallUtil.exe "C:\MyPath..\MyExe.ProcessorService.exe -service myParam"
serge
  • 13,940
  • 35
  • 121
  • 205

1 Answers1

0

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

Matt Davis
  • 45,297
  • 16
  • 93
  • 124