有没有办法从 WiX 中的安装程序 运行 卸载程序?

Is there a way to run uninstallers from an installer in WiX?

我有一套基于 WiX 的应用程序安装程序。它取代了一堆旧的安装程序,其中套件中的每个应用程序都有自己的基于 InstallShield 的安装程序。

我希望 WiX 安装程序能够找到任何基于 InstallShield 的旧安装和 运行 它们各自的卸载程序。我试过这个:

<Property Id="OLD_APPLICATION_A_UNINSTALLSTRING">
  <RegistrySearch Id="OldAppAUninstallString" Root="HKLM" 
   Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{$(var.OldAppAInstallerGUID)}"
   Name="UninstallString" Type="raw"/>
</Property>

<InstallExecuteSequence>
  <Custom Action="UninstallAppA" Before="InstallInitialize">
    NOT Installed AND OLD_APPLICATION_A_UNINSTALLSTRING
  </Custom>
</InstallExecuteSequence>

<CustomAction Id="UninstallAppA" Directory="System32"
 ExeCommand="[OLD_APPLICATION_A_UNINSTALLSTRING] /qn" Execute="immediate" Return="check"/>

这会导致安装失败和错误状态 1618:"Another installation is already in progress. Complete that installation before proceeding with this install."只有一个其他安装正在进行,此安装...

有没有办法从 WiX 中的安装程序 运行 卸载程序?

我也有一个引导程序,也许我应该 运行 以某种方式从那里进行这些卸载。但我想尽可能晚地 运行 它们,以防用户取消安装。如果发生这种情况,如果旧的应用程序套件消失了,那看起来就不太好了...

在 MSI 中有一个互斥锁可以防止两个安装事务(执行序列)同时发生 运行 因此您的错误。

您可以使用额外的升级元素通过 UpgradeCode / Version / Lanugage 找到它们,并在安装过程中删除它们。