有没有办法检查是否安装了服务,如果有,请在使用WiX 3.7卸载应用程序时将其停止并卸载它?我不希望WiX安装该服务 - 只需卸载它即可。用户卸载时停止和卸载不同的服务
我有WiX安装程序来安装几个应用程序组件,但应用程序本身可以产生一个Windows服务(取决于安装时选择的功能)。我不确定要清理的最好方法是什么 - 我想让我的设置检查该服务是否存在,并在卸载时将其删除。
我不确定是否需要CustomAction。我对使用WiX安装服务非常熟悉,但不是只要删除它们(如果存在)。
这是我的安装项目。只是为了提供一些额外的背景知识,这是一个自动更新/启动应用程序。它需要一系列XML文件来告诉它如何更新/准备应用程序。例如,如果选择“MyApp打印机”功能,它将安装一个额外的XML文件,告诉我的应用程序如何根据Web服务对本地文件进行散列检查,然后安装并启动该组件的“MyApp打印机”Windows服务。位于我的实际WiX安装项目中的Windows服务是完全不同的,并且在卸载时工作正常,所以请忽略该服务。
<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
<Product Id="*" Name="MyApp ID" Language="1033" Version="1.0.0.0" Manufacturer="MyApp ID" UpgradeCode="932dbe1f-e112-4bd0-8f60-b81850fb465b">
<Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />
<MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
<MediaTemplate EmbedCab="yes" />
<WixVariable Id="WixUILicenseRtf" Value="EULA.rtf" />
<Feature Id="ProductFeature" Title="MyApp ID Setup Core" Level="1" Absent="disallow" Display="expand">
<ComponentGroupRef Id="ProductComponents" />
<ComponentRef Id="MyAppStartMenuFolderRemove" />
<Feature Id="MyAppClientFeature" Title="MyApp ID Windows Client" Level="1" Absent="allow">
<ComponentGroupRef Id="MyAppClientComponents" />
<ComponentRef Id="MyAppStartMenuIcon" />
</Feature>
<Feature Id="MyAppPrinterFeature" Title="MyApp ID Printer App" Level="2" Absent="allow">
<ComponentGroupRef Id="MyAppPrinterComponents" />
<ComponentRef Id="PrinterStartMenuIcon" />
</Feature>
</Feature>
<UIRef Id="WixUI_FeatureTree" />
<UIRef Id="WixUI_ErrorProgressText" />
</Product>
<Fragment>
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="ProgramFilesFolder">
<Directory Id="MyAppBaseFolder" Name="MyAppID">
<Directory Id="INSTALLFOLDER" Name="MyAppLauncher">
<Directory Id="UPDATESCRIPTSFOLDER" Name="Scripts" />
</Directory>
</Directory>
</Directory>
<Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="MyApp ID"/>
</Directory>
</Directory>
</Fragment>
<Fragment>
<DirectoryRef Id="ApplicationProgramsFolder">
<Component Id="PrinterStartMenuIcon">
<Shortcut Id="PrinterStartMenuShortcut"
Name="MyApp ID Printer UI"
Description="Manage the MyApp ID Printer Service"
Icon="MyAppPrinterIcon"
Target="[INSTALLFOLDER]AutoUpdater.exe"
Arguments="MyAppPrinter"
WorkingDirectory="INSTALLFOLDER">
<Icon Id="MyAppPrinterIcon" SourceFile="$(var.AutoUpdater.Launcher.TargetDir)\Resources\MyApp_printer_white.ico" />
</Shortcut>
<RegistryValue Root="HKCU" Key="Software\Microsoft\MyApp.CardPrinter.Service" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
<Component Id="MyAppStartMenuIcon">
<Shortcut Id="MyAppStartMenuShortcut"
Name="MyApp ID"
Description="Run the MyApp ID Windows Client software"
Target="[INSTALLFOLDER]AutoUpdater.exe"
Arguments="MyAppClient"
WorkingDirectory="INSTALLFOLDER"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\MyApp.WindowsClient" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
</Component>
<Component Id="MyAppStartMenuFolderRemove">
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
<RegistryValue Root="HKCU" Key="Software\Microsoft\MyApp.WindowsClient" Name="installedFolder" Type="integer" Value="1" KeyPath="yes"/>
</Component>
</DirectoryRef>
</Fragment>
<Fragment>
<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
<Component Id="LibrariesComponent" Guid="7ED3B3B3-A984-44ED-9BA3-841F53CEA114">
<File Source="$(var.AutoUpdater.Foundation.TargetPath)" Vital="yes" KeyPath="yes" />
<File Source="$(var.AutoUpdater.Module.TargetPath)" Vital="yes" />
<File Source="$(var.AutoUpdater.Module.WebService.TargetPath)" Vital="yes" />
</Component>
<Component Id="ServiceComponent" Guid="CAB8D997-5798-4B9D-8CA0-78AACE58932E">
<File Source="$(var.AutoUpdater.Service.TargetPath)" Vital="yes" KeyPath="yes" />
<File Source="$(var.AutoUpdater.Service.TargetDir)\AutoUpdater.Service.exe.config" Name="AutoUpdater.Service.exe.config" Vital="yes" />
<ServiceInstall Name="ServiceComponentInstall" Id="ServiceComponentInstall" DisplayName="MyApp ID Launcher" Account="LocalSystem" ErrorControl="normal" Type="ownProcess" Start="auto" Vital="yes" />
<ServiceControl Name="ServiceComponentInstall" Id="ServiceComponentControl" Start="install" Stop="both" Remove="uninstall" Wait="yes" />
</Component>
<Component Id="LauncherComponent">
<File Source="$(var.AutoUpdater.Launcher.TargetPath)" Vital="yes" />
<File Source="$(var.AutoUpdater.Launcher.TargetDir)\Resources\MyApp_printer_white.ico" Name="MyApp_printer_white.ico" />
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<ComponentGroup Id="MyAppClientComponents" Directory="UPDATESCRIPTSFOLDER">
<Component Id="MyAppClientXml">
<File Source="$(var.AutoUpdater.Service.TargetDir)\Scripts\MyAppClient.xml" Name="MyAppClient.xml" />
</Component>
</ComponentGroup>
</Fragment>
<Fragment>
<ComponentGroup Id="MyAppPrinterComponents" Directory="UPDATESCRIPTSFOLDER">
<Component Id="MyAppPrinterXml">
<File Source="$(var.AutoUpdater.Service.TargetDir)\Scripts\MyAppPrinter.xml" Name="MyAppPrinter.xml" />
</Component>
</ComponentGroup>
</Fragment>
</Wix>
我希望这不是太混乱:)。提前致谢!
编辑:
谢谢你抢,解决办法是在<ServiceControl>
元素添加到最后一个片段:
<Fragment>
<ComponentGroup Id="MyAppPrinterComponents" Directory="UPDATESCRIPTSFOLDER">
<Component Id="MyAppPrinterXml">
<File Source="$(var.AutoUpdater.Service.TargetDir)\Scripts\MyAppPrinter.xml" Name="MyAppPrinter.xml" />
<ServiceControl Id="NukeMyAppPrinterService" Name="MyApp ID Printer Service" Remove="uninstall" Stop="uninstall" />
</Component>
</ComponentGroup>
</Fragment>
它将作品是否是“MyApp的ID打印机服务”安装或不。我喜欢简单的解决方案!
非常感谢罗布,我要去尝试这就是现在。我正在阅读文档,但专注于ServiceInstall元素。我会告诉你,如果这个工作在一分钟内!谢谢! – 2013-04-26 19:03:32
再次感谢Rob,这就是我所需要的!我用我的最终代码更新了我的问题。 – 2013-04-26 19:16:03