代码之家  ›  专栏  ›  技术社区  ›  ChickenFeet

在WiX安装程序中设置服务启动类型

  •  2
  • ChickenFeet  · 技术社区  · 8 年前

    我正在尝试将预装服务的启动类型设置为 Automatic ,使用WiX。另一项任务是在安装时启动服务,这是我通过以下方式实现的:

    <ServiceControl 
        Id="ServiceRunningState" 
        Name="[Service Name]" 
        Start="install"
        Stop="install"
        Wait="yes" /> 
    

    现在我还要设置启动类型。我尝试了以下方法(参见 answer ):

    <ServiceConfig
        Id="ServiceStartup" 
        ServiceName="[Service Name]"
        DelayedAutoStart="yes"
        OnInstall="yes" 
        OnReinstall="yes" />
    

    但这并没有改变服务的启动类型(从 Manual 启动类型)。此外,我希望启动类型为 自动的 Automatic (Delayed Start) .

    请注意,我正在尝试修改 现有服务 ,因此没有 ServiceInstall 要素

    这两个要素( ServiceControl ServiceConfig )儿童是否在 Component 父元素。

    感谢您的帮助:)

    3 回复  |  直到 8 年前
        1
  •  2
  •   Bob Arnson    8 年前

    MSI不支持更改软件包未安装的服务的启动类型。 ServiceConfig doesn't let you get around that :

    仅适用于已安装的自动启动服务或此软件包安装的服务,SERVICE\u auto\u start位于ServiceInstall表的StartType字段中。

        2
  •  1
  •   ChickenFeet    8 年前

    通过编辑注册表解决 RegistryKey ,参见示例:

    <RegistryKey Root="HKLM"
                 Key="SYSTEM\CurrentControlSet\Services\[Service Name]"
                 Action="create">
        <RegistryValue Type="integer" Name="Start" Value="2" />
        <RegistryValue Type="integer" Name="DelayedAutostart" Value="0" />
    </RegistryKey>
    

    注意:服务可能显示为 Automatic (Delayed Start) 在服务GUI中。但是,重新启动后,服务GUI将服务启动类型显示为 Automatic .

        3
  •  0
  •   Calum MacLeod    8 年前

    将“DelayedAutoStart”参数设置为“no”,而不是“yes”。