首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >WiX -修改已安装的产品后重新启动服务

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

Stack Overflow用户
提问于 2012-01-31 00:02:44
回答 2查看 3K关注 0票数 2

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

在用户修改已安装的产品之后(等式,添加新功能),则需要重启windows服务。在WiX 3.5中,有没有比调用自定义操作重启服务更优雅的方法呢?

这就是我启动服务的方式。

代码语言:javascript
运行
复制
<ServiceControl Id="StartService" Name="MyService" Start="install" Stop="both" Remove="uninstall"  Wait="yes" />

编辑:这是完整的组件代码。忽略ids。

代码语言:javascript
运行
复制
<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>

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2012-02-01 00:11:08

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

代码语言:javascript
运行
复制
<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>

票数 2
EN

Stack Overflow用户

发布于 2012-01-31 06:24:32

这个解决方案对我很有效:

代码语言:javascript
运行
复制
<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>
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/9066804

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档