WiX - 修改已安装产品后重新启动服务

时间:2012-01-30 16:02:44

标签: service wix installer

我正在编写一个安装Windows服务的MSI,并添加了一些服务使用的DLL。这些DLL是可以使用安装程序添加或删除的功能。

用户修改已安装的产品(例如添加新功能)后,需要重新启动Windows服务。除了调用可以重启服务的自定义操作之外,还有更优雅的方式在WiX 3.5中这样做吗?

这就是我开始服务的方式。

<ServiceControl Id="StartService" Name="MyService" Start="install" Stop="both" Remove="uninstall"  Wait="yes" />

编辑: 这是完整的组件代码。无视ids。

<Component Id="MyService" Guid="GUID">
     <File Id="MyService"
      Source="$(var.BuildDestination)/$(var.NameSpacePrefix).MyService.exe"
      KeyPath="yes"
      >
</File>
<RemoveFile Id='AppConfigFile' On='uninstall' Name='MyService.exe.Config' />
<User xmlns="http://schemas.microsoft.com/wix/UtilExtension"
         Id="ServiceAccount"
         CreateUser="no"
         FailIfExists="no"
         RemoveOnUninstall="no"
         UpdateIfExists="yes"
         Disabled="no"
         LogonAsService="yes"
         Name="[ACCOUNT]"
         Password="[PASSWORD]" />
<ServiceInstall
          Id="MyService"
          Type="ownProcess"
          Vital="yes"
          Name="MyService"
          DisplayName="MyService"
          Description="MyService"
          Start="auto"
          Account="[ACCOUNT]"
          Password="[PASSWORD]"
          ErrorControl="ignore"
          Interactive="no">
</ServiceInstall>
<ServiceControl Id="StartService"
                Name="MyService"
                Start="install"
                Stop="both"
                Remove="both"
                Wait="yes"
                >
</ServiceControl>

2 个答案:

答案 0 :(得分:2)

由于服务功能的状态(安装和启动服务的功能)未更新,因此服务本身也未停止并启动。 我已经通过将ServiceControl添加到作为单独功能的所有组件来解决了这个问题。

<Component Id="Modules1" Guid="GUID">
<File Id="Modules.1" Source="$(var.BuildDestination)/$(var.NameSpacePrefix)Modules.1.dll" KeyPath="yes">
</File>
<ServiceControl Id="StartService1"
               Name="MyService"
               Start="install"
               Stop="both"
               Wait="yes"
                >
</ServiceControl>

答案 1 :(得分:1)

此解决方案适用于我:

<Component Directory="APPLICATIONFOLDER">
    <File           Source      ="MyService.exe"
                    KeyPath     ="yes" />
    <ServiceInstall Id          ="MyService.exe"
                    Name        ="My Service"
                    Account     ="LocalSystem"
                    Start       ="auto"
                    ErrorControl="normal"
                    Interactive ="no"
                    Type        ="ownProcess"
                    Description ="My service does stuff."/>
    <ServiceControl Id          ="MyService.exe"
                    Name        ="My Service"
                    Start       ="install"
                    Stop        ="both"
                    Remove      ="both"
                    Wait        ="no"/>
</Component>
相关问题