How to conditionally install a prerequisite based on the user selection?

ImportantThe following article uses options that are available starting with the Enterprise edition and project type.

This tutorial will guide you step by step through the creation of a Windows Installer package that will conditionally install a prerequisite based on the user selection.

Let's suppose that your application requires a runtime to be installed on the target machine but the related runtime can only be installed if the user agrees.

1. Add prerequisite

In order to allow the user to decide if a certain prerequisite will be installed or not, you can add the prerequisite and schedule it During Main Package or After Main Package in the Prerequisites page. To add a prerequisite that is not in the predefined list of prerequisites, you can proceed as follow:

  • Adding bundled prerequisite software. Use the [ Package Prerequisite ] toolbar button, “New Package Prerequisite” context menu item or Insert key. You will be prompted to pick the prerequisite setup files.
  • Adding downloadable prerequisite software. For this, you can use the [ URL Prerequisite ] toolbar button or "New URL Prerequisite” context menu item.

NotePlease keep in mind that this type of prerequisite is created with default settings, so you need to configure it manually (e.g. define proper install conditions for the prerequisite in the prerequisite conditions tab).

2. Create the selection dialog

In the Dialogs page, you can create the custom dialog where the user will select if the prerequisite will be installed or not.

Let's consider the case where the user will have a radio button group control with the options to install or not the additional package, as you can see below:

Options dialog

The INSTALL_ADDITIONAL_PACKAGES property attached to the radio button group control will contain the selected option by the user during installation.

3. Condition the feature installation

In the Organization page, you can condition the feature installation.

Each prerequisite schedule During Main Package or After Main Package creates its feature entry in the Organization page. You can condition the feature installation through the installation behavior section from the feature properties. You can condition the feature installation as you can see in the below image:

Feature props

So, the feature will be scheduled for installation based on the user selection.

ImportantWhen the prerequisite have certain install conditions defined then it will be installed based its install conditions, even if the user selected to install the prerequisite. To read more about how a prerequisite is installed, follow the How a prerequisite is scheduled for installation? article.

Below there is a short video with the above steps.