简体   繁体   English

wix:安装/卸载完成后重新启动现有服务

[英]wix: re-start an existing Service when install/uninstall finish

I would like to re-start a running service when my installer finish installing or uninstalling. 当我的安装程序完成安装或卸载后,我想重新启动正在运行的服务。
I have found this code: 我找到了以下代码:

<ServiceControl Id="SomeUniqueId" Name="NameOfTheirService"
            Start="both" Stop="both"/>

But where do i attach this code to ? 但是我要将这段代码附加到哪里? to the component where my is placed ? 到放置我的组件?

Code: 码:

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="325c4bfd-6614-43e9-aedb-93661295352d" Name="Plugin" Language="1033" Version="1.0.0.0"
       Manufacturer="XXX Inc." UpgradeCode="4307526e-3902-40d0-991b-bacff9b3d71b">
<Package InstallerVersion="200" Compressed="yes" />
<Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />
<Property Id="XXXXXX">
  <RegistrySearch Id="XXXXXX" Type="raw" 
                  Root="HKLM" Key="SOFTWARE\XXX\XXX" Name="InstallationPath" />

</Property>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="XXXXXX">
    <Component Id="ProductComponent" Guid="93118c45-f0c0-4c9e-9168-8ea905e9427c">
      <File Id="pluggin" Source="C://setup.log" KeyPath="yes" Checksum="yes"/>
      <ServiceControl Id="StartService" Name="servicename"
         Start="both" Stop="both"/>
    </Component>     
    </Directory>
    </Directory>
    <Feature Id="ProductFeature" Title="install" Level="1">
        <ComponentRef Id="ProductComponent" />
  <ComponentGroupRef Id="Product.Generated" />
    </Feature>
</Product>

The ServiceControl element must be placed in a component that you install. 必须将ServiceControl元素放置在您安装的组件中。 From the WiX .chm: 从WiX .chm:

Starts, stops, and removes services for parent Component. 启动,停止和删除父组件的服务。 This element is used to control the state of a service installed by the MSI or MSM file by using the start, stop and remove attributes. 此元素用于通过使用开始,停止和删除属性来控制由MSI或MSM文件安装的服务的状态。 For example, Start='install' Stop='both' Remove='uninstall' would mean: start the service on install, remove the service when the product is uninstalled, and stop the service both on install and uninstall. 例如,Start ='install'Stop ='both'Remove ='uninstall'表示:在安装时启动服务,在卸载产品时删除服务,并在安装和卸载时均停止服务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM