I was recently dealing with an application install and wanted to selectively activate some features via scripting. Turns out the application had three platforms and one of the platforms had four separate options. The typical method was to use the Custom Setup, but I wanted more flexibility.
Here was the situation, I created two screens that the user would be able to choose selections; the first was a Platform screen,

And then if Balance was chosen then they could pick components (one, none or all) from the four that were available.

What I wanted to achieve was to have InstallShield features created for the following:
- CommonFiles – this contains all common files needed by application, regardless of the platform chosen
- Stability – these files would be delivered if customer selected Stability as a platform
- Balance – this was some core files for Vision that would be required when the platform Balance was selected.
- Optionally, when the these specific components for Balance are selected:
- Balance_Client – these files within this feature would be selected if the user checked the box “Client for Balance”
- Balance_CacheMonitor – these files within this feature would be selected if the user checked the box “Cache Monitor”
- Balance_SearchMonitor – these files within this feature would be selected if the user checked the box “Search Monitor”
- Balance_AuditMonitor – these files within this feature would be selected if the user checked the box “Auditing”
- Viewer – these files would be delivered if customer selected Viewer as a platform
With those dialogs and the features created, and components and files populated, how could I selectively activate the features based on user selection?
Here is how I accomplished it:
- On each feature that I wanted conditionally set, I first set the InstallLevel value to be 300 – which prevents the feature from being installed (assuming default INSTALLLEVEL property value of 100).
- You will need to create a script that runs after the dialogs have been displayed and the user makes the selection. Here is a snippet that I created:
// ******************************************************
// ** Obtain the value of the MSI Property associated
// ** with the Audit Checkbox
// ******************************************************
nBuffer = 256;
MsiGetProperty (ISMSI_HANDLE, “VER_BAL_COMPONENT_AU”,
szCS_Component_AU, nBuffer);
szBuffer = “ver–> Retrieved ‘%s’ value from the MSI Property “ +
“VER_BAL_COMPONENT_AU ‘ “;
Sprintf (szLogMessage, szBuffer, szCS_Component_AU);
ver_WriteLogFile (szLogMessage);
// ******************************************************
// ** If checkbox was checked, then set the corresponding
// ** MSI Property to be an ACTIVE switch
// ******************************************************
if (szCS_Component_AU = “1″) then
MsiSetProperty (ISMSI_HANDLE, “AUDIT_SWITCH”, “ACTIVE”);
szBuffer = “ver–> Set ‘%s’ as value for the MSI Property “ +
“’AUDIT_SWITCH’ “;
Sprintf (szLogMessage, szBuffer, “ACTIVE”);
ver_WriteLogFile (szLogMessage);
endif;
I pulled the value of the MSI Property associated with the Balance Component “Auditing”. If the value was “1” – then the user had checked the “Audit” box. All I had to do was then set the MSI Property “AUDIT_SWITCH” to have a value of “ACTIVE”.
Now this script is run by a Custom Action that is set to run after the dialogs have completed in the UI Sequence. But because the UI Sequence does not run when executing silently – you need to have the Custom Action set to “Run Only Once” and have the CA also run in the Execute Sequence.
- Finally, I created some Custom Actions that will set the MSI Property “ADDLOCAL” which is the property that lets the Windows Installer know what features are being installed. These will be Type 51 – “New Set Property” and will only run in the Execute Sequence. I will initialize the MSI Property “ADDLOCAL” with the features that are always required and then build the string, adding more features as necessary. Here are some sample Custom Actions:
- Custom Action Name: ISI_SetBaseFeatures
i. Property Name: ADDLOCAL
ii. Property Value: CommonFiles
iii. Execution Scheduling: Always Execute
iv. Install Exec Sequence: Schedule after AppSearch
v. Install Exec Condition: NOT Installed
-
- Custom Action Name: ISI_SetBalance
i. Property Name: ADDLOCAL
ii. Property Value: [ADDLOCAL],Balance
iii. Execution Scheduling: Always Execute
iv. Install Exec Sequence: Schedule after ISI_SetBaseFeatures
v. Install Exec Condition: BALANCE_SWITCH=”ACTIVE”
-
- Custom Action Name: ISI_SetAuditing
i. Property Name: ADDLOCAL
ii. Property Value: [ADDLOCAL],Balance_AuditMonitor
iii. Execution Scheduling: Always Execute
iv. Install Exec Sequence: Schedule after ISI_SetBalance
v. Install Exec Condition: AUDIT_SWITCH=”ACTIVE”
Basically, I took the MSI Property “ADDLOCAL” and initialized it to the features that I considered mandatory – in this case the feature “CommonFiles”.
From this point on, each Custom Action would append another feature to the MSI Property when the condition was met.
In the above examples, if the user chose the checkbox in the dialog “Auditing”, then after the script ran the MSI Property “AUDIT_SWITCH” was set to “ACTIVE”. That triggers the condition in Custom Action “ISI_SetAuditing” so that the feature name “Balance_AuditMonitor” will be appended to the MSI Property “ADDLOCAL” (Note: the use of apostrophe in the value!). Another feature has been activated.
Hope this sheds some light on how to make InstallShield work for you!