Custom Actions in Windows Installer
Custom Actions in Windows Installer
Windows Installer
Abstract: When creating a custom action in InstallShield Professional - Windows
Installer Edition you have several in-script execution options to choose from:
1. Immediate execution
2. Deferred execution
3. Rollback execution
4. Commit execution
5. Deferred execution in System Context
These options mean and how they affect in which phase your custom action is executed at
installation run time. It also helps you to insert the custom action in the correct location in the user
interface or execute sequence, in order to avoid error messages like can not write record.
Transaction not started.
In the user interface sequence, you can use only immediate custom actions. This
applies to the sequence table and DoAction control events as well.
The ExecuteAction standard action launches the execute sequence as a sub
procedure.
After the execute actions are finished, the installer returns to the user interface
sequence and executes any actions that may be specified after ExecuteAction. By
default there is none, but you could insert an immediate execution custom action
here, e.g. to launch another msi file.
When the script is built (i.e. InstallFinalize is reached) the installer starts to execute
the script. On NT based systems this phase runs in a separate process. All the script
execution takes place "inside" the InstallFinalize action.
During this phase the deferred execution custom actions are executed, along with all
the standard actions. They are executed in the order they have been written to the
script in the script creation phase, and only if their condition was true at the time the
script was built.
Because this phase runs in a separate process, deferred execution customs actions
cannot directly access installer properties, and they cannot set the value of any
property.
Rollback Execution
While the installer executes the installation script, it builds a rollback script. For any
standard action in the installation script, a rollback command is added to the rollback
script. The installer cannot automatically undo changes that custom actions make to
the target system. Instead it adds any rollback custom actions to the rollback script.
In addition, backup copies of any files that the installer overwrites are stored in a
temporary directory.
Rollback actions are added in the order they are encountered in the installation
script, but only if their condition was true at the time the installation script was built.
If the installation is cancelled by the user or aborted because of an error during
script execution, the rollback script is executed to undo any changes that have been
made to the target system. This is when the rollback custom actions are executed.
The rollback script is processed from bottom up, i.e. most recent actions are undone
first.
When the installer has finished to process the installation script without interruption,
the rollback script and all backup files are deleted, and any commit custom actions
are executed.
If Rollback has been disabled on the target computer, no rollback script is created,
and no backup copies of replaced files are made.
Commit Execution
Commit custom actions are the opposite of rollback actions. They are added to a
commit script while the installation script is executed, much in the same way that
rollback custom actions are added to the rollback script.
Commit actions are added to the commit script only if their condition was true at the time the
installation script was built.
The commit script is executed at the end of the InstallFinalize action, when the installation script
has been processed, and only if installation has not been aborted.
The purpose of commit actions is to remove any backup information that had been created by a
custom action.
A sample for the use of deferred, rollback and commit custom actions
Imagine a custom action that would modify an existing file. This should be a deferred
execution custom action, so that this change can be undone if the setup is cancelled.
Therefore the custom action would first make a backup copy of the file and then
modify it.
The rollback custom action would delete the modified file and replace it with the backup copy. It
If Rollback has been disabled on the target computer, no commit script is created. Commit is the
counterpart of rollback. If rollback is disabled, your custom action should not create backup files,
and therefore commit execution actions are ignored in this case.