Question

I made a Wix project that attemps to install a simple .txt example file. But, as a prerequisite, I want to uninstall a previous application.

To do so, I know msiexec allows you to uninstall a product by simply writing:

msiexec /x {PRODUCT_CODE}

on a command line.

Fortunately, I know this PRODUCT_CODE, so I tried to create a CustomAction to uninstall that product before the installation starts, like this:

<CustomAction Id="PropertyAssign" Property="SilentLaunch" Value="msiexec.exe /x {EA29682C-7DA1-441C-BF3E-702491F59258}" Execute="immediate" />
<CustomAction Id="SilentLaunch" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="check" Impersonate="no" />

<InstallUISequence>
  <Custom Action="PropertyAssign" After="CostFinalize" />
  <Custom Action="SilentLaunch" After="PropertyAssign" />
</InstallUISequence>

But when I run the .msi, it says there was an unexpected error with code 2762 and exits installation.

I know the mistake is in that line, as if I erase it, everything goes ok.

Any idea on how to run that command line without any mistakes?

Was it helpful?

Solution

The UI sequence should never make changes to the state of the machine. It should only gather, validate and report data to the user. All changes must be made in the execute sequence.

There is a mutex in Windows / MSI ( _MSIExecute ) that enforces one execute sequence per machine. Therefore you cannot call msiexec from an MSI. But what you can do is author a Major Upgrade rule to detect the other product and remove it. The Windows Installer standard action RemoveExisitingProducts can uninstall any MSI not just previous versions of yourself.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top