Skip to content

Instantly share code, notes, and snippets.

@mxpv
Last active April 18, 2018 19:16
Show Gist options
  • Save mxpv/2935715 to your computer and use it in GitHub Desktop.
Save mxpv/2935715 to your computer and use it in GitHub Desktop.
InstallShield Custom Actions notes

Deferred Custom Actions

To adhere to the Windows Installer "Best Practices," all changes that are made to a system are in a "deferred" action.

A deferred execution custom action must be scheduled in the execute sequence table within the section that performs script generation.

Deferred execution custom actions must come after "InstallInitialize" and come before "InstallFinalize" in the action sequence.

You can only call the following functions in this type of action:

  • MsiGetProperty
  • MsiFormatRecord
  • MsiGetMode
  • MsiGetLanguage
  • MsiProcessMessage

Only the following limited set of properties are always accessible to custom actions during script execution ( (i.e. deferred custom action).

Conditional Statement Syntax

Feature and component state values:

Feature

! - Installed state
& - Action state

Component

? - Installed state
$ - Action state

State values

1 - Advertised feature. This state is not available for components.
2 - Feature or component is not present.
3 - Installed local.
4 - Feature or component run from the source.

Sources:

Examples:

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"

Finally, to only run an action during uninstall use the following condition:

REMOVE

Install:

&feature=3

Reinstall, upgrade:

!feature=3 AND &feature<>2

Action run only during Install Condition: NOT Installed AND NOT PATCH

Action only runs during removal of MSI Condition: REMOVE

Action runs during Install and repair Condition: NOT REMOVE

Action runs during Install and remove Condition: There must be no condition

Action calls EXE installed by MSI Condition:NOT Installed AND NOT PATCH

Run on initial installation only: NOT Installed

Run on initial install or when repair is selected. NOT Installed OR MaintenanceMode="Modify"

Run when being uninstalled from command line or add / remove menu. REMOVE~="All" OR MaintenanceMode="Remove"

@trueqbit
Copy link

trueqbit commented Apr 18, 2018

It's worth mentioning that the documentation for Windows Installer's Session.FeatureRequestState mentions msiInstallStateDefault=5, which corresponds to INSTALLSTATE_DEFAULT which MsiGetFeatureState might return.

I found by reading the installer logs that MSI would record a feature as REINSTALL when doing a repair.
I am using &Feature=3 or &Feature=5 to run a custom action when installing or repairing a product.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment