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

时间:2021-04-05 23:00:39

I am creating MSI installer using Wix for wpf applications.I am creating 2 projects one is Wix set up project and another is a Bootstrapper. There is a file named product.wxs in Setup project and Bundle.wxs in Bootstrapper project.I am creating shortcut in product.wxs file as shown in below code. I have reference of set up project in Bootstrapper. I can see this short cut in start menu. When I run this shortcut, it removes application from c:\ where it was installed previously.But it still shows the entry in Control panel(Add or Remove programs).This case happens when I use Exe created by Bootstrapper project.But When I use installer created by Set Up project, it works well.The entry from control panel is also gets removed. I am not able to figure out what is happening with bootstrapper project. This is my code for Product.wxs from SetUp project:

我正在使用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>

Following is code for Bundle.wxs from Bootstrapper project:

以下是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 个解决方案

#1


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>

Also add to your Feature element:

还要添加到Feature元素:

<ComponentRef Id="ApplicationShortcut" />

#2


0  

Bootstrapper was creating 2 entries in control panel.But I was showing only entry of Bootstrapper project and I was hiding MSI installer exe like

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

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

So whenever I tried to uninstall it from shortcut, the shortcut was actually uninstalling installer which was not visible in control panel.i.e.it was uninstalling installer created using SetUp project with product.wxs. Now I just changed the visibility of 2 entries. This time I am Keeping MSI installer visible and Bootstrapper entry is hidden. The following is little change in code:

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

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

Above code from Bundle.wxs will disables the entry of Bootstrapper in Control panel. One more change I made in Chain element by keeping Msipackage visible. The following is change:

Bundle.wxs上面的代码将禁用控制面板中Bootstrapper的输入。通过保持Msipackage可见,我在Chain元素中做了一个更改。以下是变化:

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

#3


0  

This is a follow up to @DT sawant answer: Unfortunately, your solution would present several problems, one of which is the windows logo rules. By hiding the bundle and making the application installed by the bundle visible in ARP, the bundle becomes stranded. That is, uninstalling the application via your 'shortcut' will remove the application, but the boostrapper is still there (invisible). So, if you try to re-install the application via the bootstrapper, then the maintenance UI shows up, instead of a fresh install as intended. In general, it seems like the convenient use of uninstall shortcut and ARP features, in tandem, is not supported in WIX or recommended best practice. It would be nice to have this though.

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

#1


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>

Also add to your Feature element:

还要添加到Feature元素:

<ComponentRef Id="ApplicationShortcut" />

#2


0  

Bootstrapper was creating 2 entries in control panel.But I was showing only entry of Bootstrapper project and I was hiding MSI installer exe like

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

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

So whenever I tried to uninstall it from shortcut, the shortcut was actually uninstalling installer which was not visible in control panel.i.e.it was uninstalling installer created using SetUp project with product.wxs. Now I just changed the visibility of 2 entries. This time I am Keeping MSI installer visible and Bootstrapper entry is hidden. The following is little change in code:

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

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

Above code from Bundle.wxs will disables the entry of Bootstrapper in Control panel. One more change I made in Chain element by keeping Msipackage visible. The following is change:

Bundle.wxs上面的代码将禁用控制面板中Bootstrapper的输入。通过保持Msipackage可见,我在Chain元素中做了一个更改。以下是变化:

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

#3


0  

This is a follow up to @DT sawant answer: Unfortunately, your solution would present several problems, one of which is the windows logo rules. By hiding the bundle and making the application installed by the bundle visible in ARP, the bundle becomes stranded. That is, uninstalling the application via your 'shortcut' will remove the application, but the boostrapper is still there (invisible). So, if you try to re-install the application via the bootstrapper, then the maintenance UI shows up, instead of a fresh install as intended. In general, it seems like the convenient use of uninstall shortcut and ARP features, in tandem, is not supported in WIX or recommended best practice. It would be nice to have this though.

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