【问题标题】:Uninstall exe using shortcut from control panel using Wix使用 Wix 从控制面板使用快捷方式卸载 exe
【发布时间】:2014-10-16 12:47:30
【问题描述】:

我正在使用 Wix 为 wpf 应用程序创建 MSI 安装程序。我正在创建 2 个项目,一个是 Wix 设置项目,另一个是引导程序。在 Setup 项目中有一个名为 product.wxs 的文件,在 Bootstrapper 项目中有一个名为 Bundle.wxs 的文件。我正在 product.wxs 文件中创建快捷方式,如下面的代码所示。我在 Bootstrapper 中有设置项目的参考。我可以在开始菜单中看到这个快捷方式。当我运行此快捷方式时,它会从以前安装它的 c:\ 中删除应用程序。但它仍然显示控制面板中的条目(添加或删除程序)。这种情况发生在我使用由 Bootstrapper 项目创建的 Exe 时。但是当我使用由设置项目创建的安装程序,它运行良好。控制面板中的条目也被删除。我无法弄清楚引导程序项目发生了什么。 这是我在安装项目中的 Product.wxs 代码:

  <Directory Id="ProgramMenuFolder">
    <Directory Id="ProgramMenuSubfolder" Name="Vizitech Solutions">
      <Component Id="ApplicationShortcuts" Guid="*">
        <Shortcut Id="ApplicationShortcut1" Name="Consenus Sweeper" 
                  Description="Consensus"
                  Target="[INSTALLFOLDER]ConsenusSweeper.exe" 
                  WorkingDirectory="INSTALLFOLDER">
          <Icon Id="MyAppShortCutIcon" SourceFile="Consensus_128.ico"/>
        </Shortcut>

        <Shortcut Id="UninstallProductStartMenu"
               Name="Uninstall Consensus Sweeper"
              Target="[System64Folder]msiexec.exe"
              Arguments="/x [ProductCode]"
              Description="Uninstalls Consensus Sweeper"

              >
          <Icon  Id="MyAppUninstallShortCutIcon" SourceFile="Consensus_128.ico"/>

        </Shortcut>
        <RegistryValue Root="HKCU" Key="Software\Vizitech\ConsensusSweeper"
                  Name="installed" Type="integer" Value="1" KeyPath="yes" />

        <RemoveFolder Id="ProgramMenuSubfolder" On="uninstall"/>
        <RemoveFolder Id="INSTALLFOLDER" On="uninstall"/>
      </Component>
     </Directory>
  </Directory>

以下是来自 Bootstrapper 项目的 Bundle.wxs 的代码:

    <Bundle Name="Consensus Sweeper" Version="1.0.0.2" 
            UpgradeCode="PUT-GUID-HERE" 
            IconSourceFile="$(var.SolutionDir)Libs\Resources\Consensus_128.ico">
<BootstrapperApplicationRef Id="WixStandardBootstrapperApplication.RtfLicense" >
  <bal:WixStandardBootstrapperApplication LicenseFile="License.rtf"  
        LogoFile="FTB.bmp" LogoSideFile="FTB.bmp" />

</BootstrapperApplicationRef>

    <Chain>
  <PackageGroupRef Id="NetFx45Web"/>
  <MsiPackage Id="MyApplication" SourceFile="$(var.ConsensusSweeper.TargetPath)"
              Visible="no">
    <MsiProperty Name="ALLUSERS" Value="1"></MsiProperty>

  </MsiPackage>
    </Chain>
</Bundle>

【问题讨论】:

    标签: xml wix windows-installer shortcut


    【解决方案1】:
    <Component Id="ApplicationShortcut" Guid="*">
        <CreateFolder/>
        <Shortcut Id="ApplicationStartMenuShortcut" 
                  Name="Consenus Sweeper" Description="Consensus"/>
    
        <Shortcut Id="UninstallProduct"
                  Name="Uninstall My Application"
                  Target="[System64Folder]msiexec.exe"
                  Arguments="/x [ProductCode]"
                  Description="Uninstalls Consensus Sweeper"/>
        <RemoveFolder Id="ProgramMenuSubfolder" On="uninstall"/>
    </Component>
    

    同时添加到您的 Feature 元素中:

    <ComponentRef Id="ApplicationShortcut" />
    

    【讨论】:

    • 您使用的是什么版本的 WiX?
    • 我正在使用 Wix Toolset v3.8
    • 我也在使用 3.8,对我来说也是从控制面板卸载...尝试手动删除然后重试...
    • 如果您的卸载快捷方式代码与我不同,您能分享您的代码吗?
    • 还有1个问题,您是否手动设置Product元素的ID?因为[ProductCode] 是那个ID @edit 我的意思是如果你有Id="*"Id="Your_guid"?我的代码是一样的,我什至不知道我看起来是否正确,因为你说卸载正在工作,但它只停留在控制面板中......
    【解决方案2】:

    Bootstrapper 在控制面板中创建了 2 个条目。但我只显示了 Bootstrapper 项目的条目,并且我隐藏了 MSI 安装程序 exe,例如

    <MsiPackage Id="MyApplication" SourceFile="$(var.ConsensusSweeper.TargetPath)"
              Visible="no">
    

    因此,每当我尝试从快捷方式卸载它时,该快捷方式实际上是在卸载在控制面板中不可见的安装程序。也就是说,它正在卸载使用带有 product.wxs 的 SetUp 项目创建的安装程序。 现在我只是改变了 2 个条目的可见性。这次我保持 MSI 安装程序可见并且 Bootstrapper 条目被隐藏。 以下是代码改动不大:

     <Bundle DisableModify="yes" DisableRemove="yes">
    

    Bundle.wxs 中的上述代码将禁用控制面板中的 Bootstrapper 条目。 通过保持 Msipackage 可见,我对 Chain 元素进行了另一项更改。 以下是变化:

          <MsiPackage Id="MyApplication" SourceFile="$(var.ConsensusSweeper.TargetPath)" Visible="yes" >
    

    【讨论】:

      【解决方案3】:

      这是@DT sawant 回答的后续:不幸的是,您的解决方案会出现几个问题,其中之一是 Windows 徽标规则。通过隐藏捆绑包并使捆绑包安装的应用程序在 ARP 中可见,捆绑包就会陷入困境。也就是说,通过“快捷方式”卸载应用程序将删除应用程序,但 boostrapper 仍然存在(不可见)。因此,如果您尝试通过引导程序重新安装应用程序,则会显示维护 UI,而不是按预期进行全新安装。通常,WIX 或推荐的最佳实践似乎不支持方便地同时使用卸载快捷方式和 ARP 功能。不过有这个就好了。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2012-08-05
        • 1970-01-01
        • 1970-01-01
        • 2011-08-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多