arghol
arghol

Reputation: 795

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

I have a WiX based installer for a suite of applications. It replaces a bunch of old installers where each application in the suite had its own InstallShield based installer.

I would like the WiX installer to find any old InstallShield based installations and run their respective uninstallers. I have tried this:

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

This results in a failed installation and error status 1618: "Another installation is already in progress. Complete that installation before proceeding with this install." Only one other installation is in progress, this installation...

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

I also have a bootstrapper and maybe I should run these uninstallations from there somehow. But I want to run them as late as possible in case the user cancels the installation. If that happens it doesn't look too good if the old application suite is gone...

Upvotes: 1

Views: 96

Answers (1)

Christopher Painter
Christopher Painter

Reputation: 55581

In MSI there is a mutex that prevents two installation transactions (execute sequence) running at the same time hence your error.

You can use additional Upgrade elements to seek them out by UpgradeCode / Version / Lanugage and cause their removal during your installation transaction.

Upvotes: 1

Related Questions