74

I'm sure this is fairly easy, but I've kind of had a hard time with it. I've got a custom action that executes a different (non-msi) installer on installation. Unfortunately, I've noticed that it also executes the installer on UNinstallation!

I've looked through the options but I cant' seem to find out how to stop this. If anybody could help me I would be incredibly grateful.

Also, how do I set a custom action to go off only during UNinstall? Any help is greatly appreciated guys!

Cyprus106
  • 5,722
  • 6
  • 40
  • 48
  • 5
    For a reference: [**Common MSI Conditions Cheat Sheet**](http://blogs.flexerasoftware.com/installtalk/2013/04/installer-cheat-sheet-series.html). – Stein Åsmul Apr 20 '15 at 20:42

5 Answers5

172

Add a condition on the action so it's only triggered during installation, not uninstallation.

Action run only during Install

NOT Installed AND NOT PATCH

Action runs during Install and repair

NOT REMOVE

Run on initial installation only:

NOT Installed

Run on initial install or when repair is selected.

NOT Installed OR MaintenanceMode="Modify"

To only run an action during uninstall use the following condition:

REMOVE~="ALL"

To only run an action during upgrade:

Installed AND NOT REMOVE
Cody S
  • 4,744
  • 8
  • 33
  • 64
saschabeaumont
  • 22,080
  • 4
  • 63
  • 85
  • 1
    @Rasa what do you mean by reinstall mode? There is no such thing in MSI parlance, you are probably looking for "Repair" (NOT REMOVE). If you log the MSI output you can see exactly what the various values used in the above conditions will be set to and figure out which one would match your situation. – saschabeaumont Jun 08 '12 at 22:19
  • 1
    What about Modify? Running an action only when a feature is uninstalled? Running an action only when a feature is being installed? Running an action only when a feature is Repaired? – Didier A. Jul 29 '13 at 13:35
  • thank you so much it helps me a lot. i was going crazy.. NOT REMOVE helped me – ertan2002 Apr 25 '17 at 16:22
  • 1
    In addition to the link I added to the question, here is a direct link to the cheat sheet PDF. No guarantees, I have not tested these conditions myself, but they are from Installshield, so they should be OK: [**Common MSI Conditions**](https://resources.flexerasoftware.com/web/pdf/archive/IS-CHS-Common-MSI-Conditions.pdf). – Stein Åsmul Aug 19 '17 at 14:02
8

A bit of a correction:

Finally, to only run an action during uninstall use the following condition: REMOVE="ALL"

This seems more appropriate as the property REMOVE contains the features being uninstalled.
So if I do a modify to remove one feature, REMOVE is true and the action that was to execute only on uninstall executes on modify.
More details here on MSDN

Hakan Fıstık
  • 16,800
  • 14
  • 110
  • 131
7

An example:

<InstallExecuteSequence>
..
    <Custom Action="QtExecIdOfCA" Before="InstallFinalize">NOT Installed</Custom>
..
</InstallExecuteSequence>

..
..
<CustomAction Id="QtExecIdOfCA" BinaryKey="WixCA" DllEntry="CAQuietExec" Execute="deferred" Return="ignore" Impersonate="no"/>

Notice! Condition is added to the <Custom> tag and not the <CustomAction> it confused me, because Custom is followed by Action attribue

kristoffer_o
  • 590
  • 5
  • 7
5

Please be careful with REMOVE=ALL. It is not available before installvalidate sequence.
And check below links for more details:
http://msdn.microsoft.com/en-us/library/aa371194(v=vs.85).aspx
http://msdn.microsoft.com/en-us/library/aa368013(v=vs.85).aspx

Hakan Fıstık
  • 16,800
  • 14
  • 110
  • 131
Andy
  • 338
  • 3
  • 10
1

A condition on the custom action, probably with a matching custom action to do the uninstall. Not sure what tools you're using, but assuming the secondary install is tied to a component, I would use that component state. A state of =3 means a target state of installed. A state = 2 means a target state of absent. Note that the state won't be set if there is no change.

Darren Clark
  • 2,983
  • 20
  • 15