简体   繁体   中英

How to execute Custom Action before RemoveExistingProducts with After=“InstallValidate” in WiX

I have something like this:

<InstallExecuteSequence>
  <RemoveExistingProducts After="InstallValidate"/>
</InstallExecuteSequence>

Since one of the uninstallation fails i need to execute a Custom Action to solve the problem BEFORE RemoveExistingProducts. Something in the lines of:

<CustomAction Id="FixStuff" .. />

<InstallExecuteSequence>
  <Custom Action="FixStuff" Before="RemoveExistingProducts" />
  <RemoveExistingProducts After="InstallValidate"/>
</InstallExecuteSequence>

This of course doesn't work since Custom Action cannot be before InstallInitialize. I'd really like to remove existing products between InstallValidate and InstallInitialize, but i'd like to execute FixStuff before removing existing products.

Is it even possible to do that?

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

Some possible approaches would be:

  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.).

  2. 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. Repair the broken MSI by using this method:

    • fix the problem in the old MSI
    • create a BAT or EXE bootstrapper which recaches it through this command:

    msiexec /fv <path_to_msi>

    • distribute this MSI as an update before your new package

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM