WiX:将服务安装为 LocalService
我正在尝试通过 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 并没有真正提供帮助,因为每个人的反应都是“让它正常工作吧”。
只是希望在安装过程中设置并启动此服务,仅此而已。 有什么帮助吗? 谢谢!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
安装时确保 services.msc 窗口已关闭
Make sure the services.msc window is closed when you install
您是否尝试过...
根据此 doc 。 ..
Have you tried ...
Per this doc ...
参考:ServiceControl Table
ServiceControl Table 的 MSI 文档声明“Name”是服务的字符串名称。 在您的代码片段中,您的 ServiceControl“名称”设置为 ServiceInstall 的“ID”,而不是其“名称”。 因此,您的 ServiceControl 元素应为:
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:
这是另一种情况,本地系统服务可能无法安装并出现错误 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.
我花了一段时间研究这个问题,发现这是因为我在组件上而不是文件上设置了 keypath 属性。 我的 wix 文件现在看起来像:
现在我只需要弄清楚如何赋予它正确的权限......
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:
Now I just need to work out how to give it the correct permissions...
我有同样的问题。 事实证明,我在 中有一个拼写错误,其中我的
Name
与我在我创建服务项目时。这也是我的服务未卸载的问题。
I had the same problem. It turns out that I had a typo in the
<ServiceControl Id="StartService" Name="MyServiceName"
where myName
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.
遇到了同样的问题,但使用了指定的帐户,对此感到厌倦,并在安装完成后创建了一个 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.
我只是回应 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.
请注意,在 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.
我们仅在 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.