2015-12-02 111 views
4

我正在尝试为我的Windows服务创建一个WiX MSI安装程序,该安装程序将安装服务,但不会启动它。我似乎无法找到解释如何做到这一点的地方,或者如果可能的话。WiX MSI安装Windows服务而不启动它

我试图删除我用于启动服务的ServiceControl以及在没有任何运气的情况下切换ServiceInstall上的Start属性。它必须可以做到这一点,对吧?我只想让MSI文件安装该服务,并让用户在需要时启动它。

<Component Id="ServiceInstaller" Guid="9e578e3d-0339-425c-8633-f54ffaaa4921"> 

    <ServiceInstall Id="ReportingServiceInstaller" 
        Type="ownProcess" 
        Vital="yes" 
        Name="WindowsService.exe" 
        DisplayName="WindowsService" 
        Description="Wickedly awesome and amazing service." 
        ErrorControl="ignore" 
        Account="NT AUTHORITY\LocalService" 
        Start="auto" 
        Interactive="no" /> 

    <ServiceControl Id="ServiceControl_Stop" 
        Name="WindowsService.exe" 
        Stop="both" 
        Remove="uninstall" 
        Wait="no" /> 

</Component> 
+0

如何启动属性?似乎“需求”比“开始”更有前途的价值。 http://wixtoolset.org/documentation/manual/v3/xsd/wix/serviceinstall.html –

+0

试图改变它,不显示在services.msc – devfunkd

回答

4

不要使用ServiceControl元素,因为它将启动和停止服务。通过调用它,您要求安装程序使用服务执行某些操作。你只需要调用ServiceInstall来创建一个服务。正如Stefan Wanitzek建议的那样,您应该在ServiceInstall的Start属性中使用需求。这是为了让用户重新启动计算机时服务不会开始运行。如果您的安装程序也将安装.exe作为安装服务的文件。我建议使用以下代码:

<Component Id="ServiceInstaller" Guid="3e412e3d-0339-325c-8633-f54ffaaa4921"> 
     <File Id="WindowsService.exe" 
     Name="WindowsService.exe" 
     KeyPath="yes" 
     Source="Path to the EXE"/> 
     <ServiceInstall Id="ReportingServiceInstaller" 
       Type="ownProcess" 
       Vital="yes" 
       Name="WindowsService"      
       DisplayName="WindowsService" 
       Description="Wickedly awesome and amazing service." 
       ErrorControl="ignore" 
       Account="NT AUTHORITY\LocalService" 
       Start="demand" 
       Interactive="no" /> 
</Component> 
+0

我不能使用文件,我的文件被添加使用因此,如果我添加它,Wix会给我一个它已经存在的错误,我无法引用它所在的组件,因为我不知道该ID。 – devfunkd

+0

删除服务控件时会发生什么?它是否看不到服务创建?尝试使用msiexec进行安装并使用/ log标志获取更多信息 – ProjectNapalm

+0

我正在使用相同的文件ID,您的答案解决了问题。 – devfunkd

相关问题