在 WiX 安装程序中设置服务启动类型 [英] Set service Startup type in WiX installer
问题描述
我正在尝试使用 WiX 将预安装服务的启动类型设置为 Automatic
.另一个任务是在安装时启动服务,我是通过以下方式实现的:
I am trying to set a pre-installed service's startup type to Automatic
, using WiX. Another task was to start the service on install, which I achieved with:
<ServiceControl
Id="ServiceRunningState"
Name="[Service Name]"
Start="install"
Stop="install"
Wait="yes" />
现在我还想设置启动类型.我尝试了以下方法(请参阅答案):
Now I would also like to set the startup type. I have tried the following (see answer):
<ServiceConfig
Id="ServiceStartup"
ServiceName="[Service Name]"
DelayedAutoStart="yes"
OnInstall="yes"
OnReinstall="yes" />
但这并没有改变服务的启动类型(从Manual
启动类型测试).此外,我希望启动类型为 Automatic
,而不是 Automatic (Delayed Start)
.
But this didn't change the startup type of the service (tested from Manual
startup type). And besides, I want the startup type to be Automatic
, not Automatic (Delayed Start)
.
请注意,我正在尝试修改现有服务,因此没有 ServiceInstall
元素.
Please note that I am trying to modify an existing service, so there is no ServiceInstall
element.
这两个元素(ServiceControl
和 ServiceConfig
)是 Component
父元素中的子元素.
The two elements (ServiceControl
and ServiceConfig
) are children within a Component
parent element.
感谢任何帮助:)
推荐答案
通过RegistryKey
编辑注册表解决,见示例:
Solved by editing the registry via RegistryKey
, see example:
<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>
Note 服务在服务 GUI 中可能显示为 Automatic (Delayed Start)
.但是,重新启动后,服务 GUI 将服务启动类型显示为 Automatic
.
Note service may appear as Automatic (Delayed Start)
in Services GUI. However, after restarting, Services GUI displayed the service startup type as Automatic
.
这篇关于在 WiX 安装程序中设置服务启动类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!