How to run custom action based on condition?

Facy87 picture Facy87 · Feb 9, 2015 · Viewed 9.2k times · Source

I'm trying to run a custom action (delete a certain file) based on the windows version. I know how to check for the windows version:

<Condition Message="Windows version xxx required...">
    <![CDATA[Installed OR (VersionNT >= 600)]]>
</Condition>

However, I do not want to display a message, but delete a file. I can't find an example on how to use such a condition to run oder not to run a custom action!

Answer

user145400 picture user145400 · Feb 9, 2015

You need to specify the condition inside the Custom element which runs your custom action. (This allows you to run the custom action multiple times in different locations in your sequence and with different conditions each time if desired).

Example:

<InstallExecuteSequence>
  <Custom Action="CreateRegistryEntries" After="CostInitialize">
    NOT Installed AND NOT PATCH
  </Custom>
</InstallExecuteSequence>