Windows Installer, Java Installer, Freeware Installer
Home|Contact|Site Map|TOC|Search
Download  Features   Java  Licensing  Purchase  Testimonials  Support  Forums

How do I show a custom feature selection dialog?

Answer

NoteThis How-To can be implemented only in an Advanced Installer Enterprise project.

This article explains how to select which features will be installed by using checkboxes and radio buttons. First, you need to create the features for your project in the Organization page. For example:

  • "Feature 1" with the Identifier Feature1
  • "Feature 2" with the Identifier Feature2
  • "Feature 3" with the Identifier Feature3
  • "Feature A" with the Identifier FeatureA
  • "Feature B" with the Identifier FeatureB
  • "Feature C" with the Identifier FeatureC
Use checkboxes to select which features will be installed
  • go to the Dialogs page and create a new dialog
  • select the custom dialog and set the "Dialog Name" field in the Properties pane to "FeatureSelectionDlg"
  • create three checkboxes on the "FeatureSelectionDlg" dialog
  • for each checkbox set the "Text" field in the "Properties" pane to an explanatory text (for example: "Install feature 1", "Install feature 2" and "Install feature 3")
  • set the properties associated with the checkboxes to CHECK1, CHECK2 and CHECK3 (you can set the property of a checkbox in the "Property Name" field)
  • for each checkbox set the "Value" field to install
  • create a new text file and rename it to "FeatureAction.vbs" (a VBScript file)
  • open it in a text editor and add this code to it:
' Set contants for the INSTALLSTATE_ABSENT and INSTALLSTATE_LOCAL feature states
Const msiInstallStateAbsent = 2
Const msiInstallStateLocal  = 3

' Set the install state of the feature with the identifier "Feature1"
If Session.Property("CHECK1") = "install" Then 
  Session.FeatureRequestState("Feature1") = msiInstallStateLocal
Else
  Session.FeatureRequestState("Feature1") = msiInstallStateAbsent
End If

' Set the install state of the feature with the identifier "Feature2"
If Session.Property("CHECK2")="install" Then
  Session.FeatureRequestState("Feature2") = msiInstallStateLocal
Else
  Session.FeatureRequestState("Feature2") = msiInstallStateAbsent
End If

' Set the install state of the feature with the identifier "Feature3"
If Session.Property("CHECK3")="install" then
  Session.FeatureRequestState("Feature3") = msiInstallStateLocal
Else
  Session.FeatureRequestState("Feature3") = msiInstallStateAbsent
End If
  • this code will set the install action for the features "Feature 1", "Feature 2" and "Feature 3" based on the checkboxes in the "FeatureSelectionDlg" dialog
  • save and close the VBS file
  • go to the Custom Actions page
  • add the VBS file as a "New Attached Custom Action" under the UI Custom Actions section
  • make sure that the "Function Name" field is empty
  • optionally, choose a suggestive name for this custom action, for instance "SetFeatureStates"
  • go to the "Dialogs" page and select the [ Next ] button on the "FeatureSelectionDlg" dialog
  • create a "DoAction" control event which looks like this:
DoAction      SetFeatureStates      AI_INSTALL

The control event on the [ Next ] button will launch the VBScript custom action. This custom action will set the install action for the features in your project depending on the state of the checkboxes.

Use radio buttons to select which features will be installed
  • go to the "Dialogs" page and select the "FeatureSelectionDlg" dialog
  • add a radio button group and three radio buttons in it
  • select the radio button group
  • in the "Properties" pane set the "Property Name" field to RADIO
  • select the first radio button and set the "Text" field in the "Properties" pane to "Install Feature A"
  • set the "Value" field to RadioFeatureA
  • set the "Selected" combo to True
  • select the second radio button and set the "Text" field in the "Properties" pane to "Install Feature B"
  • set the "Value" field to RadioFeatureB
  • select the third radio button and set the "Text" field in the "Properties" pane to "Install Feature C"
  • set the "Value" field to RadioFeatureC
  • add this code to the "FeatureAction.vbs" file:
' Initialize the install states of the mutually exclusive features 
' and set their states based on the radio button selection
Session.FeatureRequestState("FeatureA") = msiInstallStateAbsent
Session.FeatureRequestState("FeatureB") = msiInstallStateAbsent
Session.FeatureRequestState("FeatureC") = msiInstallStateAbsent

If Session.Property("RADIO") = "RadioFeatureA" Then
  Session.FeatureRequestState("FeatureA") = msiInstallStateLocal
ElseIf Session.Property("RADIO") = "RadioFeatureB" Then
  Session.FeatureRequestState("FeatureB") = msiInstallStateLocal
ElseIf Session.Property("RADIO") = "RadioFeatureC" Then
  Session.FeatureRequestState("FeatureC") = msiInstallStateLocal
End If
  • save and close the VBS file
  • rebuild the project

The code you added to the VBScript file will set the install action of the features "Feature A", "Feature B" and "Feature C" based on the selected radio button.

Download and unzip the sample project to better understand how to configure your own project. An Enterprise version of Advanced Installer (version 6.2 or greater) is required in order to build and run the project. However, you can use any Enterprise version of Advanced Installer greater than 4.0 to implement this functionality into your own project.

Privacy Policy | Windows Installer | Search Engine Ranking | Link Analyzer