WiX:将服务安装为 LocalService

发布于 2024-07-26 22:36:11 字数 1273 浏览 2 评论 0 原文

我正在尝试通过 WiX 3.0 获取我的应用程序的安装程序。 确切的代码是:

<File Id="ServiceComponentMain" Name="$(var.myProgramService.TargetFileName)" Source="$(var.myProgramService.TargetPath)" DiskId="1" Vital="yes"/>

<!-- service will need to be installed under Local Service -->
<ServiceInstall
                        Id="MyProgramServiceInstaller"
                        Type="ownProcess"
                        Vital="yes"
                        Name="MyProgramAddon"
                        DisplayName="[removed]"
                        Description="[removed]"
                        Start="auto"
                        Account="LocalService"
                        ErrorControl="ignore"
                        Interactive="no"/>
<ServiceControl Id="StartDDService" Name="MyProgramServiceInstaller" Start="install" Wait="no" />
<ServiceControl Id="StopDDService" Name="MyProgramServiceInstaller" Stop="both" Wait="yes" Remove="uninstall" />

问题是,由于某种原因,LocalService 在“安装服务”步骤中失败,如果我将其更改为“LocalSystem”,则安装程序在尝试启动服务时会超时。

该服务可以手动启动并在系统启动时正常启动,并且无论出于何种目的和目的,该服务都运行良好。 我听说在 LocalService 下让服务正常工作存在问题,但 Google 并没有真正提供帮助,因为每个人的反应都是“让它正常工作吧”。

只是希望在安装过程中设置并启动此服务,仅此而已。 有什么帮助吗? 谢谢!

I am trying to get my application an installer via WiX 3.0. The exact code is:

<File Id="ServiceComponentMain" Name="$(var.myProgramService.TargetFileName)" Source="$(var.myProgramService.TargetPath)" DiskId="1" Vital="yes"/>

<!-- service will need to be installed under Local Service -->
<ServiceInstall
                        Id="MyProgramServiceInstaller"
                        Type="ownProcess"
                        Vital="yes"
                        Name="MyProgramAddon"
                        DisplayName="[removed]"
                        Description="[removed]"
                        Start="auto"
                        Account="LocalService"
                        ErrorControl="ignore"
                        Interactive="no"/>
<ServiceControl Id="StartDDService" Name="MyProgramServiceInstaller" Start="install" Wait="no" />
<ServiceControl Id="StopDDService" Name="MyProgramServiceInstaller" Stop="both" Wait="yes" Remove="uninstall" />

Thing is, for some reason LocalService fails on the "Installing services" step, and if I change it to "LocalSystem" then the installer times out while trying to start the service.

The service starts fine manually and at system startup, and for all intents and purposes works great. I've heard there are issues getting services to work right under LocalService, but Google isnt really helping as everyone's responses have been "got it to work kthx".

Just looking to get this service set up and started during installation, that's all. Any help? Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(10

¢好甜 2024-08-02 22:36:11

安装时确保 services.msc 窗口已关闭

Make sure the services.msc window is closed when you install

动听の歌 2024-08-02 22:36:11

您是否尝试过...

NT AUTHORITY\LocalService 

根据此 doc 。 ..

...但账户名必须是NT
调用时的 AUTHORITY\LocalService
创建服务,无论
区域设置,或者意外的结果可能
发生。

Have you tried ...

NT AUTHORITY\LocalService 

Per this doc ...

... but the name of the account must be NT
AUTHORITY\LocalService when you call
CreateService, regardless of the
locale, or unexpected results can
occur.

无声无音无过去 2024-08-02 22:36:11

参考:ServiceControl Table

ServiceControl Table 的 MSI 文档声明“Name”是服务的字符串名称。 在您的代码片段中,您的 ServiceControl“名称”设置为 ServiceInstall 的“ID”,而不是其“名称”。 因此,您的 ServiceControl 元素应为:

<ServiceControl Id="StartDDService" Name="MyProgramAddon" Start="install" Wait="no" />
<ServiceControl Id="StopDDService" Name="MyProgramAddon" Stop="both" Wait="yes" Remove="uninstall" />

reference: ServiceControl Table

The MSI documentation for ServiceControl Table states that the 'Name' is the string name of the service. In your code snipet, your ServiceControl 'Name' is set to the 'ID' for the ServiceInstall and not its 'Name'. So, your ServiceControl elements should read:

<ServiceControl Id="StartDDService" Name="MyProgramAddon" Start="install" Wait="no" />
<ServiceControl Id="StopDDService" Name="MyProgramAddon" Stop="both" Wait="yes" Remove="uninstall" />
泪意 2024-08-02 22:36:11

这是另一种情况,本地系统服务可能无法安装并出现错误 1923:如果您已经安装了具有相同 DisplayName(但内部服务名称、路径等不同)的另一个服务。 我刚刚就遇到过这种事。

Here is another case where a localsystem service can fail to install with error 1923: if you have another service already installed with the same DisplayName (but different internal service name, path, etc). I just had this happen to me.

李不 2024-08-02 22:36:11

我花了一段时间研究这个问题,发现这是因为我在组件上而不是文件上设置了 keypath 属性。 我的 wix 文件现在看起来像:

<Component Id="comp_WF_HOST_18" DiskId="1" KeyPath="no" Guid="3343967A-7DF8-4464-90CA-7126C555A254">
    <File Id="file_WF_HOST_18" Checksum="yes" Source="C:\Projects\GouldTechnology\Infrastructure\WorkflowHost\WorkflowHost\bin\Release\WorkflowHost.exe" KeyPath="yes"/>

      <ServiceInstall
                 Id="workflowHostInstaller"
                 Type="ownProcess"
                 Vital="yes"
                 Name="WorkflowHost"
                 DisplayName="Workflow Host"
                 Start="demand"
                 Account="[WORKFLOW_HOST_USER_ACCOUNT]"
                 Password="[WORKFLOW_HOST_USER_PASSWORD]"
                 ErrorControl="critical"
                 Interactive="no"/>
    <ServiceControl Id="StartWFService" Name="workflowHostInstaller" Start="install"  Stop="both" Remove="both" Wait="no" />

</Component>

现在我只需要弄清楚如何赋予它正确的权限......

I spent a while looking into this and discovered it was because I had the keypath attribute set on the the component not on the file. My wix file now looks like:

<Component Id="comp_WF_HOST_18" DiskId="1" KeyPath="no" Guid="3343967A-7DF8-4464-90CA-7126C555A254">
    <File Id="file_WF_HOST_18" Checksum="yes" Source="C:\Projects\GouldTechnology\Infrastructure\WorkflowHost\WorkflowHost\bin\Release\WorkflowHost.exe" KeyPath="yes"/>

      <ServiceInstall
                 Id="workflowHostInstaller"
                 Type="ownProcess"
                 Vital="yes"
                 Name="WorkflowHost"
                 DisplayName="Workflow Host"
                 Start="demand"
                 Account="[WORKFLOW_HOST_USER_ACCOUNT]"
                 Password="[WORKFLOW_HOST_USER_PASSWORD]"
                 ErrorControl="critical"
                 Interactive="no"/>
    <ServiceControl Id="StartWFService" Name="workflowHostInstaller" Start="install"  Stop="both" Remove="both" Wait="no" />

</Component>

Now I just need to work out how to give it the correct permissions...

阳光①夏 2024-08-02 22:36:11

我有同样的问题。 事实证明,我在 中有一个拼写错误,其中我的 Name 与我在我创建服务项目时。

这也是我的服务未卸载的问题。

I had the same problem. It turns out that I had a typo in the <ServiceControl Id="StartService" Name="MyServiceName" where my Name did not match the service name I specified in the service project when I created it.

This was also the problem with my service not uninstalling.

万劫不复 2024-08-02 22:36:11

遇到了同样的问题,但使用了指定的帐户,对此感到厌倦,并在安装完成后创建了一个 CA 来启动服务。 只是不要费心尝试使用 MSI 启动它,只需将其留给 CA,除非您从某处获得一些质量信息。

顺便说一句,使用 LocalSystem 和手动启动的服务工作正常。 从来没有任何其他变体可以工作。

Had the same problem but with specified accounts, got bored of it and created a CA to start the service after the install was completed instead. Just don't bother trying to start it with MSI, just leave it to a CA, unless you get some quality info from somewhere.

BTW using LocalSystem and a manually started service works fine. Never got any other variations to work.

撩起发的微风 2024-08-02 22:36:11

我只是回应 aristippus303 的建议:不要尝试使用 Windows Installer 启动服务,也不要设置任何帐户,只需在安装过程中接受默认的 LocalSystem 即可。 尝试做任何其他事情都太有问题了。 Windows Installer 等待服务表明它已启动,并且有太多的事情可能会出错,例如权限和权限、防火墙设置以及丢失的文件等等,因此 Windows Installer 最终会冻结或因错误而终止并且您的安装失败。

您想要做的是在文档中指定用户应手动更改服务的帐户(如有必要)并在安装完成后手动启动服务,并解决此时出现的任何问题。 或者只是告诉用户重新启动,以便在您相当确定不会出现问题的情况下自动启动选项将启动服务。

I'll just echo aristippus303's advice: Don't try to start a service with Windows Installer, and don't set any account, just accept the default of LocalSystem during installation. Trying to do anything else is too problematic. Windows Installer waits for the service to indicate it has started, and there are too many things that can go wrong, what with permissions and rights and firewall settings and missing files and so on, so then Windows Installer ends up frozen or terminating with an error and your install has failed.

What you want to do is to specify in your documentation that the user should manually change the service's account (if necessary) and manually start the service after the install is done, and to trouble-shoot any problems that turn up at that point. Or just tell the user to reboot so the auto-start option will start the service if you're fairly sure that there won't be problems.

东走西顾 2024-08-02 22:36:11

请注意,在 ServiceInstall 元素的文档中,有关 Account 属性的内容是“启动服务的帐户。仅当 ServiceType 为 ownProcess 时有效。”。 在您的示例中,您没有指定 ownProcess 服务类型,这可能是问题所在。

Please pay attention that in the documentation for ServiceInstall element it is written about the Account attribute that "The account under which to start the service. Valid only when ServiceType is ownProcess.". In your example you did not specify the ownProcess service type which may be the problem.

冬天旳寂寞 2024-08-02 22:36:11

我们仅在 Windows XP 计算机上出现相同的问题,无法安装该服务。 最后我们发现,在 XP 上,WiX 文件中的名称设置被忽略,而是使用 C# 代码中设置的服务名称。 我们碰巧在代码中有一个包含空格的名称,即“Blah Blah Service”,当将其设置为与 Windows 7 上使用的 WiX 文件相同的名称时,它运行良好。

We had the same problem occuring only on Windows XP machines were the service could not be installed. In the end we found that on XP the name setting from the WiX file is ignored and it instead used the service name set in the C# code. We happened to have a name in the code that contained white-space, i. e. "Blah Blah Service", when this was set to the same name as the WiX file used on Windows 7 it worked well.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文