如何使用 WiX 在 NetworkService 帐户下安装和启动 Windows 服务?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2003404/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to install and start a Windows Service under NetworkService account by using WiX?
提问by Ray
I am trying to create a wix installer to install and start a Windows Service under NetworkService account, but failed, what I got is "Service"() could not be installed. Verify that you have sufficient privileges to install system services."
我正在尝试创建一个 wix 安装程序来安装和启动 NetworkService 帐户下的 Windows 服务,但失败了,我得到的是无法安装“Service”()。验证您是否有足够的权限来安装系统服务。”
Please advice, my code is as below:
请指教,我的代码如下:
<Component Id="service" Guid='myguid'>
<File Id='JobServiceEXE' Name='JobService.exe' DiskId='1' Source='mypath\JobService.exe' KeyPath='yes' />
<ServiceControl Id="JobService" Name="[SERVICEID]" Stop="uninstall" Remove="uninstall" Wait="yes" />
<ServiceInstall
Id="JobService" Name="[SERVICEID]" DisplayName="[SERVICENAME]" Type="ownProcess" Start="auto" ErrorControl="normal" Vital ='yes'
Account="NT Authority\NetworkService"
Description="Job Service" />
</Component>
Thank you!
谢谢!
采纳答案by Paul Lalonde
First, the message you're getting may be due to a security issue. Your installer must be run by an administrator because creating services requires administrative privileges. You might check for that in a Condition
element.
首先,您收到的消息可能是由于安全问题。您的安装程序必须由管理员运行,因为创建服务需要管理权限。您可能会在Condition
元素中检查它。
Second, using NT Authority\NetworkService
as the account name will fail on non-English systems, because built-in account names are localized. Instead, use plain old NetworkService
which Wix recognizes specially and resolves into the correct localized name.
其次,NT Authority\NetworkService
在非英语系统上用作帐户名将失败,因为内置帐户名是本地化的。相反,使用NetworkService
Wix 特别识别并解析为正确的本地化名称的普通旧。
回答by Marc
Paul's response is not correct. As per MSDN documentation, to specify the Network Service account, use "NT AUTHORITY\NETWORK SERVICE":
保罗的回答是不正确的。根据 MSDN 文档,要指定网络服务帐户,请使用“NT AUTHORITY\NETWORK SERVICE”:
...the name of the account must be
NT AUTHORITY\NETWORKSERVICE
when you call CreateServiceor ChangeServiceConfig, regardless of the locale...
...帐户名称必须是
NT AUTHORITY\NETWORKSERVICE
当您调用CreateService或ChangeServiceConfig 时,无论语言环境如何...
Set the property "ALLUSERS" to force an Administrator install.
设置属性“ALLUSERS”以强制管理员安装。
see thislink for further information
请参阅此链接以获取更多信息
回答by JLWarlow
I've been having this one on Windows 7 and it was bugging me for ages. I fixed it by adding
我一直在 Windows 7 上使用这个,它一直困扰着我多年。我通过添加修复它
InstallScope="perMachine"
To my package element:
对于我的包元素:
<Package Description="..."
Manufacturer="Microsoft Corporation"
InstallerVersion="200"
Languages="1033"
Compressed="yes"
InstallScope="perMachine"/>