created the topic: Guidelines for Custom Action Location
Place the custom action as high in the sequence as possible where it executes properly. If it doesn’t execute properly when you test it, keep moving it lower in the sequence until it works.
If the custom action uses information that’s gathered during the User Interface sequence, place it after the actions that gather the information you need.
If the installation is run silently, items in the User Interface sequence do not execute.
If the action does this: Place it in this sequence:
Gathers input from an end user
Needs to change properties
User Interface or Execute Immediate
Is an Install MSI custom action
Is to be executed sometime during the installation of files
Execute Immediate or Execute Deferred
Place it between the InstallInitialize and InstallFinalize actions, near the InstallFiles action. The InstallFiles action installs files during deferred mode.
Makes a change to the system
Depends on a previous action in order to run
Windows Installer does not perform the action when it runs in Immediate mode. If a custom action depends on a change to the system, and the change has not yet been made, the custom action fails.
Requires elevated privileges to run
Actions run in Deferred mode can be run under the system context. See the description of the In-Script Options field in Using the Custom Action Properties Tab.
* If an action has restrictions on its placement in the sequence, the restricted areas are shaded in the Installation Sequence list when you select the action in the Actions list. Place the action in a non-restricted area. Restrictions are defined by Windows Installer functionality. Example: You can’t run an action that depends on an installed file if the file is not yet installed.
* If you use the Move Up and Move Down commands on a custom action that has restricted placement, keep in mind that the restricted areas will not be shaded. Before moving an action, select the action in the Actions list to view its restricted areas.
* Formatted Text
* If you use formatted text in a custom action, such as a bracketed property name, the custom action must be placed after the CostFinalize action in the User Interface sequence. This is a Windows Installer requirement.
* If you use formatted text in a custom action, do not put the custom action in the Execute Deferred sequence. Formatted text strings do not convert in the Execute Deferred sequence. The exceptions to this rule are the CustomActionData and ProductCode properties. See Formatted and Obtaining Context Information for Deferred Execution Custom Actions in the Windows Installer SDK Help.