2009-12-21 108 views
44

我试图在Wix中使用下面的代码。如何使用WiX安装和启动Windows服务

但是在安装时,安装程​​序在状态上冻结了3分钟:启动服务,然后收到此消息“服务作业服务无法启动,请确认您有足够的权限启动系统服务”。 我的密码有问题吗?我可以让用户在安装过程中输入windows系统的用户名和密码来获得“权限”吗?

非常感谢!

<File Id='JobServiceEXE' Name='JobService.exe' DiskId='1' 
     Source='JobService.exe' Vital='yes' KeyPath='yes'/>   
    <ServiceInstall Id="ServiceInstaller" Type="ownProcess" Vital="yes" 
     Name="JobService" DisplayName="123 Co. JobService" 
     Description="Monitoring and management Jobs" Start="auto" 
     Account="LocalSystem" ErrorControl="ignore" Interactive="no" /> 
    <ServiceControl Id="StartService" Stop="both" Remove="uninstall" 
     Name="JobService" Wait="yes" /> 
</Component> 
+1

我删除了“Wait =”yes“”,现在安装正常,但在Windows任务管理器中服务“JobService”的状态为“停止”,它如何自动启动?谢谢。 – Ray

+0

ServiceInstall元素中的Start =“auto” –

回答

58

下面的代码对我的作品......没有必要提示用户名/密码:)

<File Id='JobServiceEXE' Name='JobService.exe' DiskId='1' Source='JobService.exe' KeyPath='yes'/>   
    <ServiceInstall 
     Id="ServiceInstaller" 
     Type="ownProcess" 
     Name="JobService" 
     DisplayName="123 Co. JobService" 
     Description="Monitoring and management Jobs" 
     Start="auto" 
     Account="[SERVICEACCOUNT]" 
     Password="[SERVICEPASSWORD]" 
     ErrorControl="normal" 
     /> 
     <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="JobService" Wait="yes" /> 
    </Component> 
+0

感谢您回答我的问题,但即使在重启系统后,服务的状态仍“停止”。 – Ray

+0

一旦安装完成但在重新启动之前它会手动启动吗? – saschabeaumont

+2

谢谢,它现在工作正常。我使用的可执行程序不是Windows服务的exe文件,现在我正在使用VB中写入的windows服务来启动它。 – Ray

12

,我发现这个页面上的解决方案将正确安装服务,但该元素的ServiceControl不会启动服务。

比较wix安装的服务和手动安装的服务(“JobService.exe/install”),“可执行文件的路径”字段缺少启动开关。使用ServiceInstall的arguments属性修复了这个问题;

<File Id='JobServiceEXE' Name='JobService.exe' DiskId='1' Source='JobService.exe' KeyPath='yes'/>   
    <ServiceInstall 
    Id="ServiceInstaller" 
    Type="ownProcess" 
    Name="JobService" 
    DisplayName="123 Co. JobService" 
    Description="Monitoring and management Jobs" 
    Start="auto" 
    Account="[SERVICEACCOUNT]" 
    Password="[SERVICEPASSWORD]" 
    ErrorControl="normal" 
    Arguments=" /start JobService" 
    /> 
    <ServiceControl Id="StartService" Start="install" Stop="both" Remove="uninstall" Name="JobService" Wait="yes" /> 
</Component> 

很长一段时间潜伏者,这是我在这里的第一篇文章 - 我希望它可以帮助某人。

+4

如果您需要传递一个参数来启动它,那么服务可能没有正确地遵守Windows API – saschabeaumont

+9

许多服务都将命令行参数传递给它们。 –

相关问题