使用Wix从控制面板使用快捷方式卸载exe

时间:2014-10-16 12:47:31

标签: xml wix windows-installer shortcut

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

3 个答案:

答案 0 :(得分: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>

还要添加到功能元素:

<ComponentRef Id="ApplicationShortcut" />

答案 1 :(得分:0)

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

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

因此,每当我尝试从快捷方式卸载它时,快捷方式实际上是卸载了在控制面板中看不到的安装程序.i.e.it正在卸载使用带有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" >

答案 2 :(得分:0)

这是对@DT锯材回答的跟进:不幸的是,您的解决方案会出现一些问题,其中一个是Windows徽标规则。通过隐藏捆绑包并使捆绑包安装的应用程序在ARP中可见,捆绑包变得搁浅。也就是说,通过您的快捷方式卸载应用程序&#39;将删除应用程序,但boostrapper仍然存在(不可见)。因此,如果您尝试通过引导程序重新安装应用程序,则会显示维护UI,而不是按预期进行全新安装。通常,WIX或推荐的最佳实践似乎不支持方便地使用卸载快捷方式和ARP功能。尽管如此,这将是很好的。

相关问题