Wix创建静默卸载文件

时间:2017-10-13 08:40:16

标签: wix windows-installer silent-installer uninstaller

我的想法是使用.msi安装文件制作一个卸载文件。我在这里阅读了一些有关创建卸载程序快捷方式的信息:http://wixtoolset.org/documentation/manual/v3/howtos/files_and_registry/create_uninstall_shortcut.html,但是我无法在msi构建后找到有关make uninstall文件的信息,也许是谁知道它可能?如果可能的话我怎么做呢?或者可以用cmd脚本吗?只需编写脚本即可从mashine自动卸载我的程序。我的代码是:

    <?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"><?define WpfApp1_TargetDir=$(var.WpfApp1.TargetDir)?>
    <Product Id="*" Name="SetupProject2" Language="1033" Version="1.0.0.0" Manufacturer="Andrejka" UpgradeCode="PUT-GUID-HERE">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <Property Id="WIXUI_INSTALLDIR" Value="TESTFILEPRODUCTDIR" />
    <Property Id="WixShellExecTarget" Value="[#WpfApp1.exe]" />
    <CustomAction Id="LaunchApplication" BinaryKey="WixCA"  DllEntry="WixShellExec"   Impersonate="yes" />
    <Property Id="LAUNCH_APP_ON_EXIT" Value="1" />

   <InstallExecuteSequence>
     <Custom Action='LaunchApplication' After='InstallFiles'/>
  </InstallExecuteSequence>   
    <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" />

        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate EmbedCab="yes"/>
        <Feature Id="ProductFeature" Title="SetupProject2" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="TESTFILEPRODUCTDIR" Name="SetupProject2">
             <Directory Id="ProgramFilesFolder">
                 <Directory Id="INSTALLFOLDER" Name="SetupProject2" />      
       </Directory>
            </Directory>
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
            <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
            <!-- <Component Id="ProductComponent"> -->
                <!-- TODO: Insert files, registry keys, and other resources here. -->
            <!-- </Component> -->

            <Component Id="WpfApp1.exe" Guid="*">
              <File Id="WpfApp1.exe" Name="WpfApp1.exe" Source="$(var.WpfApp1_TargetDir)WpfApp1.exe" />     
            </Component>
            <Component Id="WpfApp1.exe.config" Guid="*">
              <File Id="WpfApp1.exe.config" Name="WpfApp1.exe.config" Source="$(var.WpfApp1_TargetDir)WpfApp1.exe.config" />
            </Component>
            <Component Id="aws_sdk_net_core_support.dll" Guid="*">
              <File Id="aws_sdk_net_core_support.dll" Name="aws-sdk-net-core-support.dll" Source="$(var.WpfApp1_TargetDir)aws-sdk-net-core-support.dll" />
            </Component>
            <Component Id="AWSSDK.Core.dll" Guid="*">
              <File Id="AWSSDK.Core.dll" Name="AWSSDK.Core.dll" Source="$(var.WpfApp1_TargetDir)AWSSDK.Core.dll" />
            </Component>
            <Component Id="AWSSDK.SimpleNotificationService.dll" Guid="*">
              <File Id="AWSSDK.SimpleNotificationService.dll" Name="AWSSDK.SimpleNotificationService.dll" Source="$(var.WpfApp1_TargetDir)AWSSDK.SimpleNotificationService.dll" />
            </Component>
            <Component Id="MimeSharp.dll" Guid="*">
              <File Id="MimeSharp.dll" Name="MimeSharp.dll" Source="$(var.WpfApp1_TargetDir)MimeSharp.dll" />
            </Component>
        </ComponentGroup>
    </Fragment>
</Wix>

1 个答案:

答案 0 :(得分:0)

一般情况下,您不应该在开始菜单中放置卸载快捷方式,这实际上违反了我认为的Windows应用程序的Microsoft徽标要求。相反,您应该让人们通过添加/删除程序小程序以正常方式卸载您的产品。

更新:我找到了这个答案,其中包含有关此主题的更多信息:Shortcuts with name "Uninstall <Program Name>" are not displayed in Windows 8/8.1/10

另外,很明显,卸载是MSI文件的内置功能 - 除非主动阻止(例如某些应用程序将自己隐藏在添加/删除程序中,否则它总是自动可用)。您无需在WiX源中进行任何额外操作即可正常支持卸载。只需遵循Windows Installer指南即可“免费”。

如果您要问的是创建卸载批处理文件的方法,那么您可以在“卸载参考”中找到多种方法来卸载MSI文件:{{3} }。

简而言之,如果您拥有MSI的产品代码,只需运行下面的命令行卸载您的MSI(您可以通过查询系统找到您的产品代码,如下所述:Uninstalling an MSI file from the command line without using msiexec - 您可能需要查看它因为你自动生成产品代码,所以:

msiexec.exe /x {your-product-guid}

或者只是通过引用原始的MSI安装文件卸载,如下所示:

msiexec.exe /x "c:\filename.msi

请参阅上面的链接答案(卸载参考)以获取有关此内容的更多信息。

相关问题