Creating and Scheduling InstallScript Custom Actions that Call InstallScript Event Handlers for InstallScript MSI Projects

InstallShield 2016

Several built-in InstallScript-related custom actions were eliminated in InstallShield 12 for InstallScript MSI projects. If you upgrade an InstallScript MSI project from InstallShield 11.5 or earlier to InstallShield 2016, InstallShield removes these built-in custom actions from your project. Because these custom actions have been removed, some existing InstallScript events that were previously called by the custom actions are now called directly from InstallScript. This article identifies the eliminated custom actions and explains how add custom actions that call these InstallScript events so that the scheduling is similar to the scheduling used in InstallShield 11.5 and earlier.

The eliminated custom actions also may affect your InstallScript MSI installation if you allow the installation to run without the Setup.exe file so that the packages can be deployed through technologies such as Active Directory. The procedure for implementing this is described in Knowledge Base article Q108166 - HOWTO: Deploying an MSI Wrapped with an InstallShield Script-Based Setup.exe. Note that if you follow the procedure that is described in that article and end users launch the .msi file directly, some of the InstallScript events are never called. The reason that they are not called is that some of the InstallScript event handler functions that were previously called by built-in InstallScript-related custom actions are not called, since the InstallScript-related custom actions have been removed. If you configure your installation according to the Q108166 article, you may also need to follow the instructions below to add custom actions that call the built-in InstallScript events.

The following built-in InstallScript-related custom actions were eliminated in InstallShield 12. They are removed from InstallScript MSI projects when they are upgraded from InstallShield 11.5 or earlier to InstallShield 2016:

ISCleanupSuccess
ISCleanUpSuspend
ISCleanUpUserTerminate
ISCleanupFatalExit
ISMsiServerStartup
ISRebootPatchHandler
ISRollbackCleanup
ISStartup
OnCheckSilentInstall (For details about changes for this custom action, see OnCheckSilentInstall.)
OnFeaturesInstalled
OnFeaturesInstalling
OnInstallFilesActionAfter
OnInstallFilesActionBefore
OnMoved
OnMoving

Because these custom actions have been removed, some existing InstallScript event handlers that were previously called by the custom actions are now called directly from InstallScript. This includes the following InstallScript event handlers that are called immediately before file transfer:

Feature functions for Installing and Uninstalling
OnGeneratedMSIScript
OnGeneratingMSIScript
OnInstallFilesActionBefore
OnMoving

It also includes the following InstallScript event handlers that are called immediately after file transfer:

Feature functions for Installed and Uninstalled
OnMoved
OnInstallFilesActionAfter

These changes were made to make global variables and global pointers available for these InstallScript event handler functions. However, because previously the events were called from custom actions, the sequence of these events in relation to other custom actions that are called directly by Windows Installer has changed. Therefore, you may need to adjust your InstallScript code appropriately to account for these changes.

Except in the case of the feature event handlers, it is also possible to add custom actions that call these event handler functions so that the scheduling is similar to the scheduling used in InstallShield 11.5 and earlier. However, global variables and global pointers are not maintained between calls, as discussed in the Global Variables, Global Pointers, and SUPPORTDIR section.

Calling OnFeatureInstalling, OnFeatureUninstalling, OnFeatureInstalled, or OnFeatureUninstalled from a custom action during file transfer does not have any effect on the installation. This is because these functions are called from InstallScript just before file transfer, and they do not have any effect when they are called more than once.

To manually schedule an InstallScript custom action that calls a predefined InstallScript event handler function:

1. Open the upgraded project in InstallShield 2016.
2. Make the appropriate changes to your InstallScript file:
a. In the View List under Behavior and Logic, click InstallScript.
b. Find the event handler function in your script. You can quickly find a function by clicking the function name in the center pane of the view.
c. Rename the function to an alternate name to avoid conflicts with existing function prototypes automatically included in ifx.h. For example:
MyOnGeneratingMSIScript
MyOnMoving
MyOnMoved
d. Update the existing function to take a single HWND parameter. For example:

function MyOnGeneratingMSIScript(hMSI) begin end;

e. Add appropriate prototypes for this new function:

export prototype MyOnGeneratingMSIScript(HWND);

3. Add an InstallScript custom action that calls your renamed InstallScript event handler function:
a. In the View List under Behavior and Logic, click Custom Actions and Sequences.
b. In the center pane, right-click the Custom Actions explorer and then click New InstallScript. InstallShield adds an InstallScript custom action.
c. Type a name for the custom action; use the same name that you used to rename the InstallScript function. For example:
MyOnGeneratingMSIScript
MyOnMoving
MyOnMoved
d. Select the new InstallScript custom action that you created.
e. Set the Function Name setting to the name of the InstallScript function.
f. For the In-Script Execution setting, specify the value that is indicated in the table below.
4. Schedule the InstallScript custom action for the appropriate part of the installation:
a. In the View List under Behavior and Logic, click Custom Actions and Sequences.
b. Right-click the action or dialog that you want your InstallScript custom action to follow and click Insert. The Insert Action dialog box opens, providing a list of all the actions and dialogs that are currently associated with your project.
c. Select the InstallScript custom action that you created. If appropriate, enter a condition in the Condition box for launching the InstallScript event.
d. Click OK.

To match the previous functionality as closely as possible, set the in-script execution in step 3f and schedule the InstallScript custom actions in step 4b as follows:

Scheduling the Custom Actions

Custom Action

In-Script Execution

Location in the Sequence

OnGeneratingMSIScript

Immediate (default)

In the Installation Execute sequence between the RemoveExistingProducts and InstallInitialize actions

OnMoving

Deferred in system context

In the Installation Execute sequence between the InstallInitialize and AllocateRegistrySpace actions

OnFeaturesInstalling, which calls all the feature Installing and Uninstalling events that are defined. Note: This will not have any effect, as explained above.

Deferred in system context

In the Installation Execute sequence between the InstallInitialize and AllocateRegistrySpace actions (after OnMoving)

OnInstallFilesActionBefore

Deferred in system context

In the Installation Execute sequence between the MoveFiles and InstallFiles actions

OnFeaturesInstalled, which calls all the feature Installed and Uninstalled events that are defined. Note: This will not have any effect, as explained above.

Deferred in system context

In the Installation Execute sequence between the ScheduleReboot and InstallFinalize actions (before OnMoved)

OnMoved

Deferred in system context

In the Installation Execute sequence between the ScheduleReboot and InstallFinalize actions (before OnGeneratedMSIScript)

OnInstallFilesActionAfter

Deferred in system context

In the Installation Execute sequence between the InstallFiles and PatchFiles actions

OnGeneratedMSIScript

Immediate (default)

In the Installation Execute sequence between the ScheduleReboot and InstallFinalize actions (after OnMoved)

Note the following:

Global variables and pointers are no longer maintained between individual InstallScript custom action calls. In addition, each InstallScript custom action initializes and uses its own individual SUPPORTDIR. Therefore, you cannot share information across individual calls using files in SUPPORTDIR. For more information, see Global Variables, Global Pointers, and SUPPORTDIR.
Most Windows Installer properties are not available to deferred, commit, and rollback InstallScript custom actions. For more information, see Windows Installer Properties and Deferred, Commit, and Rollback InstallScript Custom Actions.

OnCheckSilentInstall

In InstallShield 11.5 and earlier, the OnCheckSilentInstall custom action automatically called the OnMsiSilentInstall InstallScript event if the InstallScript MSI installation was being installed silently without using Setup.exe (for example, if the following command-line was used: Msi.exe /i<Package> /qn). In InstallShield 12 and later, this event is not called in InstallScript MSI installations. However, you can add a custom action that calls the OnMsiSilentInstall event handler function. To do so, use the aforementioned instructions, noting the following scheduling requirements in steps 3f and 4b:

Scheduling the OnCheckSilentInstall Custom Action

Custom Action

In-Script Execution

Location in the Sequence

OnCheckSilentInstall

Immediate (default)

As the first action in the Installation Execute sequence

Also, to require that the InstallScript event run only in the expected scenario, add the following code to the event:

cchValueBuf = MAX_PATH;

// Check whether Setup.exe is being used, if so just return.

MsiGetProperty(nHandle, "ISSETUPDRIVEN", szValueBuf, cchValueBuf);

if(StrLengthChars(szValueBuf)) then

   return ISERR_SUCCESS;

endif;