2012-01-30 90 views
2

我正在编写安装Windows服务的MSI,并添加了服务使用的一些DLL。这些DLL是可以使用安装程序添加或删除的功能。WiX - 修改已安装产品后重新启动服务

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

这就是我开始服务的方式。编号: 这是完整的组件代码。忽视ID。

<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

随着服务功能的状态(功能,安装并启动服务)没有更新,服务本身WASN”也停下来,开始了。 我已经通过将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

该解决方案适用于我:

<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> 
+0

不幸的是,它不会为我做的伎俩。我在原始文章中添加了完整的组件代码。 – MrBob 2012-01-31 09:58:12

+0

您在Windows日志,应用程序的事件查看器中看到了什么,其中源是否为MsiInstaller或MyService? – 2012-01-31 10:31:11

+0

如果将'ErrorControl'更改为'“normal”或“c​​ritical”,会发生什么?这可能提供更多信息。 – 2012-01-31 10:34:39

相关问题