且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在使用 After="InstallValidate" 的 RemoveExistingProducts 之前执行自定义操作在 WiX 中

更新时间:2022-06-02 00:50:53

很遗憾,您无法使用当前配置在 RemoveExistingProducts 之前运行提升的自定义操作.

Unfortunately you cannot run an elevated custom action before RemoveExistingProducts with your current configuration.

一些可能的方法是:

  1. 在 InstallFinalize 之前移动 RemoveExistingProducts.这样就解决了自定义动作的问题,但是可能会出现其他问题,因为这种方法有很多限制(组件需要在版本之间维护它们的名称和GUID,你的自定义动作应该知道升级是在安装结束等时进行的).

  1. Move RemoveExistingProducts right before InstallFinalize. This solves the custom action problem, but other problems may occur since this approach has many restrictions (the components need to maintain their names and GUIDs between versions, your custom actions should be aware that the upgrade is performed at installation end etc.).

创建一个 EXE 引导程序,在启动新的 MSI 之前修复旧的安装程序.此引导程序可能需要通过清单获得管理员权限:

Create an EXE bootstrapper which fixes the old installer before launching the new MSI. This bootrapper can require Administrator privileges through a manifest:

http://msdn.microsoft.com/en-us/library/bb756929.aspx

  1. 使用此方法修复损坏的 MSI:

  1. Repair the broken MSI by using this method:

  • 修复旧 MSI 中的问题
  • 创建一个 BAT 或 EXE 引导程序,通过此命令重新缓存它:

msiexec/fv

msiexec /fv <path_to_msi>

  • 在您的新软件包之前分发此 MSI 作为更新

当您的新包运行 RemoveExistingProducts 时,旧的缓存 MSI 应该被修复并且应该正确卸载.

When your new package runs RemoveExistingProducts, the old cached MSI should be fixed and it should uninstall correctly.