【问题标题】:Install a Windows Service having parameters安装具有参数的 Windows 服务
【发布时间】:2019-03-22 15:20:30
【问题描述】:

我尝试安装具有参数的 Windows 服务。

我尝试重现这样的内容:

但似乎不可能像这样安装它:

InstallUtil.exe "C:\MyPath..\MyExe.ProcessorService.exe -service myParam"

【问题讨论】:

    标签: .net windows-services installutil


    【解决方案1】:

    据我所知,InstallUtil.exe 不支持这一点。它似乎没有用于向服务启动命令添加参数的命令行开关。

    看来您可以通过this 答案中的sc start 命令执行此操作。 net start 命令甚至可能允许您这样做,基于this 答案。

    基本上,如果您有一个名为Foo 的服务,那么感兴趣的注册表项就是ImagePath

    [HKLM\SYSTEM\CurrentControlSet\Services\Foo]
    "ImagePath":<PathToService>\MyService.exe Parameter1 Parameter2
    

    如果您按照说明here 让您的服务安装 从命令行(例如,&lt;PathToService&gt;\MyService.exe -install),您应该能够在InstallService() 调用之后添加必要的逻辑让服务使用必要的参数更新其ImagePath 注册表项。

    HTH

    【讨论】:

      猜你喜欢
      • 2010-11-06
      • 1970-01-01
      • 2011-06-19
      • 2018-10-12
      • 1970-01-01
      • 2011-09-11
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多