WiX:将服务安装为LocalService

时间:2009-07-11 20:47:15

标签: installation wix windows-installer wix3

我试图通过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并没有真正帮助,因为每个人的回答都是“让它工作到kthx”。

只是希望在安装过程中设置和启动此服务,就是这样。有帮助吗?谢谢!

10 个答案:

答案 0 :(得分:11)

确保在安装

时关闭了services.msc窗口

答案 1 :(得分:10)

你试过......

NT AUTHORITY\LocalService 

根据此doc ...

  

...但帐户名必须为NT   您致电AUTHORITY \ LocalService   CreateService,无论如何   语言环境,或意外的结果可以   发生。

答案 2 :(得分:8)

参考:ServiceControl Table

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

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

答案 3 :(得分:7)

这是另一种情况,本地系统服务可能无法安装,错误1923:如果您已经安装了另一个具有相同DisplayName(但不同的内部服务名称,路径等)的服务。我刚把这件事发生在我身上。

答案 4 :(得分:3)

有相同的问题但是使用指定的帐户,对它感到厌倦并在安装完成后创建了一个CA来启动服务。只是不要试图用MSI启动它,只需将它留给CA,除非你从某个地方获得一些质量信息。

BTW使用LocalSystem和手动启动的服务工作正常。从来没有任何其他变化工作。

答案 5 :(得分:3)

我遇到了同样的问题。事实证明我在<ServiceControl Id="StartService" Name="MyServiceName"中有一个拼写错误,我的Name与我在创建服务项目时指定的服务名称不匹配。

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

答案 6 :(得分:3)

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

您要做的是在文档中指定用户应手动更改服务的帐户(如有必要),并在安装完成后手动启动服务,并解决任何出现问题的问题点。或者只是告诉用户重新启动,如果您确信没有问题,自动启动选项将启动服务。

答案 7 :(得分:2)

我花了一些时间研究这个并发现它是因为我在组件上设置了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>

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

答案 8 :(得分:1)

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

答案 9 :(得分:1)

我们遇到了同样的问题,只有在Windows XP机器上才能安装该服务。最后,我们发现在XP上,WiX文件中的名称设置被忽略,而是使用C#代码中设置的服务名称。我们碰巧在包含空格的代码中有一个名字,i。即“Blah Blah Service”,当它设置为与Windows 7上使用的WiX文件同名时,它运行良好。