【发布时间】:2019-03-22 15:20:30
【问题描述】:
我尝试安装具有参数的 Windows 服务。
我尝试重现这样的内容:
但似乎不可能像这样安装它:
InstallUtil.exe "C:\MyPath..\MyExe.ProcessorService.exe -service myParam"
【问题讨论】:
标签: .net windows-services installutil
我尝试安装具有参数的 Windows 服务。
我尝试重现这样的内容:
但似乎不可能像这样安装它:
InstallUtil.exe "C:\MyPath..\MyExe.ProcessorService.exe -service myParam"
【问题讨论】:
标签: .net windows-services installutil
据我所知,InstallUtil.exe 不支持这一点。它似乎没有用于向服务启动命令添加参数的命令行开关。
看来您可以通过this 答案中的sc start 命令执行此操作。 net start 命令甚至可能允许您这样做,基于this 答案。
基本上,如果您有一个名为Foo 的服务,那么感兴趣的注册表项就是ImagePath:
[HKLM\SYSTEM\CurrentControlSet\Services\Foo]
"ImagePath":<PathToService>\MyService.exe Parameter1 Parameter2
如果您按照说明here 让您的服务安装 从命令行(例如,<PathToService>\MyService.exe -install),您应该能够在InstallService() 调用之后添加必要的逻辑让服务使用必要的参数更新其ImagePath 注册表项。
HTH
【讨论】: