如何使用 WiX 在 NetworkService 帐户下安装并启动 Windows 服务?
我正在尝试创建一个wix安装程序来在NetworkService帐户下安装和启动Windows服务,但失败了,我得到的是“Service”()无法安装。请确认您有足够的权限来安装系统服务。”
请指教,我的代码如下:
<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>
谢谢!
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."
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
保罗的回答是不正确的。根据 MSDN 文档,要指定网络服务帐户,请使用“NT AUTHORITY\NETWORK SERVICE”:
...设置属性“ALLUSERS”强制管理员安装。
请参阅此链接欲了解更多信息
Paul's response is not correct. As per MSDN documentation, to specify the Network Service account, use "NT AUTHORITY\NETWORK SERVICE":
Set the property "ALLUSERS" to force an Administrator install.
see this link for further information
首先,您收到的消息可能是由于安全问题造成的。您的安装程序必须由管理员运行,因为创建服务需要管理权限。您可以在
Condition
元素中检查这一点。其次,使用 NT Authority\NetworkService 作为帐户名在非英语系统上会失败,因为内置帐户名已本地化。相反,请使用 Wix 专门识别的普通旧式 NetworkService 并解析为正确的本地化名称。
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.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 oldNetworkService
which Wix recognizes specially and resolves into the correct localized name.我在 Windows 7 上一直有这个问题,它困扰了我很多年。我通过添加
到我的包元素来修复它:
I've been having this one on Windows 7 and it was bugging me for ages. I fixed it by adding
To my package element: