【问题标题】:Wix create silent uninstall fileWix 创建静默卸载文件
【发布时间】:2017-10-13 08:40:16
【问题描述】:

我的想法是使用 .msi 安装文件制作一个卸载文件。我在这里阅读了一些有关创建卸载程序快捷方式的信息:http://wixtoolset.org/documentation/manual/v3/howtos/files_and_registry/create_uninstall_shortcut.html,但是我在 msi build 之后找不到有关 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>

【问题讨论】:

  • 欢迎来到 stackoverflow - 我花了一段时间才明白你的问题,但我很高兴你似乎已经得到了你需要的东西。请不要在您的来源中发布 GUID,人们可以复制它们,然后它们就不再是唯一的(这违背了 GUID 的全部目的)。这是相当重要的。如果您还没有上线,我会生成新的组件 GUID,或者更好的是,使用将它们设置为 * 的概念,这将 自动计算组件 GUID。你也可以simplify your WiX source
  • 我来了,谢谢回答
  • 安装程序和卸载程序是 msiexec (Windows Installer)。 msi 文件是一个数据库,WiX 是用于构建它的一种工具。

标签: wix windows-installer silent-installer uninstallation


【解决方案1】:

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

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

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

如果您要的是创建卸载批处理文件的方法,那么您可以在此“卸载参考”中找到多种卸载 MSI 文件的方法:Uninstalling an MSI file from the command line without using msiexec

简而言之,如果您有 MSI 的产品代码,只需运行下面的命令行来卸载您的 MSI(您可以通过如下所述查询您的系统找到您的产品代码:How can I find the product GUID of an installed MSI setup? - 您可能需要查找它,因为您自动生成您的产品代码):

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

或者只是通过参考您的原始 MSI 安装文件来卸载,如下所示:

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

有关此问题的更多信息,请参阅上面的链接答案(卸载参考)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-09
    • 2013-06-21
    • 2010-09-16
    • 2017-09-10
    • 2011-09-11
    • 1970-01-01
    相关资源
    最近更新 更多