如何使用 WiX 在 NetworkService 帐户下安装并启动 Windows 服务?

发布于 2024-08-17 03:56:49 字数 730 浏览 2 评论 0原文

我正在尝试创建一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

浅沫记忆 2024-08-24 03:56:49

保罗的回答是不正确的。根据 MSDN 文档,要指定网络服务帐户,请使用“NT AUTHORITY\NETWORK SERVICE”:

...帐户名称必须是

NT AUTHORITY\NETWORKSERVICE

当您调用CreateServiceChangeServiceConfig时,无论区域设置如何...

...设置属性“ALLUSERS”强制管理员安装。

请参阅链接欲了解更多信息

Paul's response is not correct. As per MSDN documentation, to specify the Network Service account, use "NT AUTHORITY\NETWORK SERVICE":

...the name of the account must be

NT AUTHORITY\NETWORKSERVICE

when you call CreateService or ChangeServiceConfig, regardless of the locale...

Set the property "ALLUSERS" to force an Administrator install.

see this link for further information

简单爱 2024-08-24 03:56:49

首先,您收到的消息可能是由于安全问题造成的。您的安装程序必须由管理员运行,因为创建服务需要管理权限。您可以在 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 old NetworkService which Wix recognizes specially and resolves into the correct localized name.

活泼老夫 2024-08-24 03:56:49

我在 Windows 7 上一直有这个问题,它困扰了我很多年。我通过添加

InstallScope="perMachine"

到我的包元素来修复它:

<Package Description="..."
         Manufacturer="Microsoft Corporation"
         InstallerVersion="200"
         Languages="1033"
         Compressed="yes"
         InstallScope="perMachine"/>

I've been having this one on Windows 7 and it was bugging me for ages. I fixed it by adding

InstallScope="perMachine"

To my package element:

<Package Description="..."
         Manufacturer="Microsoft Corporation"
         InstallerVersion="200"
         Languages="1033"
         Compressed="yes"
         InstallScope="perMachine"/>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文