Windows installation and Sequences Part 2

Customization is possible at the sequence level by enabling or disabling the running of sequence. You can also insert new custom action in to sequences or change the order of execution of the actions.

To insert an action into the sequences, you can right-click the action that should precede your action and select Insert. You can also specify the type of action you want to insert (standard action, custom action,merge module action, and so forth), or specify an optional condition for the action.

For standard actions, Windows Installer typically waits for one action to complete before continuing in the sequences to the next action. One consequence of this behavior is that Windows Installer does not support performing part of a standard action, running custom code, and then completing
the standard action. For example, an installation cannot install only some files, launch a custom action, and then complete the file-transfer action. Instead, the standard InstallFiles action occurs as a
single operation, and a custom action must be called either before or after InstallFiles, but not during InstallFiles.

For a custom action, then, you must determine where it should be executed relative to other actions.A single action can be executed only once in a given subsequence, but you can schedule an action in both the UI and Execute subsequences, if necessary.You can control the behavior of a custom action that occurs in both the UI and Execute sequences using the Execution Scheduling setting: If you select Always Execute, the action is executed every time it is encountered; the option Execute Only Once executes the action only in the UI sequence for a full-UI installation, and only in the Execute sequence for a silent installation.

InstallShield provides many custom actions to enhance Windows Installer functionality, enabling support for executing SQL scripts, searching and modifying XML files, creating Web sites and virtual directories for IIS, and more.

I still need to understand the following "Windows Installer makes two passes through the Execute sequence, called immediate mode and deferred mode. Immediate mode is Windows Installer generating its internal script, and deferred mode is Windows Installer performing its internal script.". This is still not clear to me.

As Windows Installer performs system changes using standard actions, it simultaneously creates a rollback script and backs up any data the installer replaces or deletes. If the user cancels the installation during deferred execution, or if the installation fails during deferred execution, Windows Installer consults the rollback script to roll back the system to the state it was in before the installation program ran.
Changes made to the system by custom actions, however, are not logged for uninstallation. Instead, for each deferred action that modifies the target system, you should create a corresponding rollback action to undo the system changes if the installation fails or the user cancels it during deferred execution. (You will typically also need to create a corresponding uninstallation action to undo the system changes when the user uninstall’s your application.) Effectively when you write custom action make sure that  whatever additional performed by the install method  is removed completely in the uninstall method so that after uninstall the system goes back to the original state.