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

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

以下是来自启动程序项目的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个回答

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" />

我正在使用Wix Toolset v3.8。 - DT sawant
我也在使用3.8版本,对我来说从控制面板卸载也可以...尝试手动删除,然后再试一次... - Buzka91
如果你的卸载快捷方式代码与我不同,你能分享你的代码吗? - DT sawant
还有一个问题,你是手动设置_Product_元素的_ID_吗? 因为[ProductCode]就是那个ID。 @edit我的意思是,如果您有 Id =“*”Id=“Your_guid”?我的代码是相同的,我甚至不知道是否正确,因为你说卸载正在工作,但仅在控制面板中保留... - Buzka91
好的,最后一件事,如果它不能工作...我不知道,添加到你的_Component Id="ApplicationShortcuts"_元素中:<CreateFolder/> @Edit 我刚刚拿了你的代码,它运行得很好(好吧,它只是没有删除_INSTALLDIR_,但这是因为我没有从代码中删除它,控制面板看起来也很好。 - Buzka91
显示剩余3条评论

0
这是对@DT sawant答案的跟进:不幸的是,您的解决方案会出现几个问题之一是Windows徽标规则。通过隐藏包并使由包安装的应用程序在ARP中可见,包变得被搁置了。也就是说,通过您的“快捷方式”卸载应用程序将删除应用程序,但启动器仍然存在(不可见)。因此,如果您尝试通过启动器重新安装应用程序,则维护UI会显示出来,而不是像预期的那样进行全新安装。总的来说,似乎WIX不支持或建议最佳实践是同时使用卸载快捷方式和ARP功能。不过可以考虑增加此功能。

-1

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

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

每当我尝试从快捷方式卸载它时,快捷方式实际上是在卸载安装程序,而该程序在控制面板中不可见。即。它正在卸载使用product.wxs创建的SetUp项目的安装程序。 现在我只改变了2个条目的可见性。这次我保持MSI安装程序可见,而启动程序条目则隐藏。 以下是代码的小更改:
 <Bundle DisableModify="yes" DisableRemove="yes">

上面的代码来自Bundle.wxs,它将禁用控制面板中引导程序的条目。 我还在Chain元素中进行了一次更改,保持Msipackage可见。 以下是更改内容:
      <MsiPackage Id="MyApplication" SourceFile="$(var.ConsensusSweeper.TargetPath)" Visible="yes" >

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接