我有几个开始安装和启动服务的 WIX 项目。由于我需要安装程序在非英语机器上工作,我一直在使用 WixQueryOsWellKnownSID 属性来为服务提供本地化的帐户名称。
但我显然有问题;因为尽管服务已安装,但它们不会在某些语言环境中启动。到目前为止,我知道安装人员在荷兰、法国、日本和中国工作;但不在德国和比利时工作,(比利时机器上的语言是法语)。
在安装过程中,我们收到“Service 'ServiceName' failed to start. 验证您有足够的权限来启动系统服务。” 错误信息。如果我忽略该错误然后打开服务 MMC,则该服务显示为具有本地化的帐户名称(在德国机器上为 NT-AUTORITÄT\NETZWERKDIENST);如果我随后手动将服务帐户设置为网络服务,则服务 MMC 会显示 Netzwerkdienst,并且服务运行良好。
我已经用 Windows7 和 Server2008R2 对此进行了测试 - 在两个操作系统上都存在相同的问题。
WIX 服务代码:
<PropertyRef Id="WIX_ACCOUNT_NETWORKSERVICE"/>
<Component Id="ProductComponent" Guid="5bcdeb4a-9832-4a01-9863-60bc0634a8fd">
<File Id="$(var.WebLoggerSR2Service.TargetName)" Name="$(var.WebLoggerSR2Service.TargetFileName)"
Source="$(var.WebLoggerSR2Service.TargetPath)" DiskId="1" KeyPath="yes" Checksum="yes"></File>
<ServiceInstall Id="ServiceInstaller" Type="ownProcess" Name="$(var.WebLoggerSR2Service.TargetName)"
Description="!(loc.SVCINST_DESCRIPTION)"
ErrorControl="normal" Start="auto" Account="[WIX_ACCOUNT_NETWORKSERVICE]"/>
<ServiceControl Id="StartWixServiceInstaller"
Name="$(var.WebLoggerSR2Service.TargetName)" Start="install" Wait="no" />
<ServiceControl Id="StopWixServiceInstaller" Name="$(var.WebLoggerSR2Service.TargetName)"
Stop="both" Wait="yes" Remove="uninstall" />
<Util:EventSource xmlns:Util="http://schemas.microsoft.com/wix/UtilExtension"
Name="$(var.WebLoggerSR2Service.TargetName)" Log="Application"
EventMessageFile="[NETFRAMEWORK20INSTALLROOTDIR]EventLogMessages.dll" />
<RemoveFolder Id="INSTALLLOCATION" On="uninstall"/>
</Component>
Run Code Online (Sandbox Code Playgroud)
我在 Visual Studio 2012 上使用带有 Votive 的 WIX 版本 3.9.16.0