How to set feature to install based on Condition

book

Article ID: 179953

calendar_today

Updated On:

Products

Symantec Products

Issue/Introduction

 

Resolution

Question
How so I set a feature to install based on condition?

Answer

Each feature in your installation is a distinct part of your application's functionality. For example, a feature can install a spell checker or sample files for your application. Each installation has an installation level, an integer from 1 to 32,767, stored in the INSTALLLEVEL property. In an installation created with a Wise Solutions product, the default value for INSTALLLEVEL is 3. Each feature's installation level is stored in the Feature Table.

The default value for a feature's install level depends on the option selected from the Level drop-down list on the Feature Details dialog. To open the Feature Details dialog, open the Features page in Installation Expert and double-click the appropriate feature. The install level associated with the option displays in the Custom Value field. The following options are available:

  • Normal. The feature's level value is set to 3, and the feature is installed by default.
  • Never install this feature. The feature's level value is set to 0, and the feature does not display in the setup program during installation and does not install.
  • Always install this feature. The feature's level value is set to 1, and the feature is installed by default.
  • Custom. Choose this option to enable the Custom Value field. Enter the appropriate install level value in this field. For example, if you want a feature to be available but not installed by default, set the value to greater than 3 and less than or equal to 1000.

If you include the Select Feature dialog or a custom dialog that contains the Selection Tree control to your installation, the user can override any values you set by selecting the features they want to install. However, the default options are based on the install level value you specify for the feature.

In addition to setting the defaults for a feature by selecting the appropriate option in the Feature Details dialog, you can conditionally set the default value the user sees. To do this, populate the Condition table. In the Condition table, you can modify the selection state of a feature based on a conditional expression.

Warning: Editing table data is not recommended unless you are an experienced Windows Installer developer with a clear understanding of Windows Installer database technology. Deleting, adding, or editing raw table data using this interface might result in unexpected, undesirable results, including damage to your installation. Altiris/Wise provides access to this information for its advanced users, but cannot provide answers for questions related to the Windows Installer database that do not specifically involve a Altiris/Wise application itself. Therefore, technical support for direct table editing is not available.

The Condition table contains three columns: Feature_, Level, and Condition.

  • Feature_. The property in this column appears also in the Feature column of the Feature table. To view a list of all the Features in your installation, click the drop-down list in the Feature_ column.
  • Level. In this column, Windows Installer specifies the install level of the feature if the Condition column's expression evaluates to TRUE.
  • Condition. To set the install level of a feature, the condition must be true. If the condition value evaluates as false, then the value entered in the Feature table determines the install level of the feature.

Any conditional statement, such as a test for a specific property setting, can serve as a basis to the value set in the Level column. The following example describes how to setup a condition that will enable a specific feature to display during installation on the operating system if it is XP and not to display if it is not an XP machine.

To set an install level based on an operating system you need to create a feature and add in conditions.

Create Features in the project:

  1. Open your installation in Wise for Windows Installer, Wise for Visual Studio .NET, or Windows Installer Editor in Wise Package Studio.
  2. In Installation Expert, open the Features page.
  3. Click the Add button. The Feature Details dialog appears.
  4. Create a feature following the steps below:
    a.  Name the feature ‘XP’.
    b. Accept all of the default options leaving the Level set to Normal.

Create a condition that will install a feature based on detecting an XP operating system:

  1. Go to Setup Editor, click the Tables tab then select the Condition table.
  2. Right-click and select New Row.
  3. From the Feature_ column, select the XP feature you just added in Installation Expert.
  4. Enter "0" in the Level column (which makes that feature unavailable)
  5. Enter VerstionNT<>501 into the Condition column.
  6. Repeat the process above to add in the opposite condition for the XP feature.  A 3 should be placed into the Level column and VersionNT=501.  (This make the feature available when the condition is true.)

Feature_

Level

Condition

Feature_2

3

VersionNT=501

Feature_1

0

VerstionNT<>501


When the installation is run on a machine with an operating system other than Windows XP, the install level of the feature is set to 0.  If the installation runs on Windows XP, then the install level for the feature is set to 3 and the user sees the feature as an available option.

By setting the install level for features, you can create an installation that installs only those features you define. The Conditions table lets you modify the install level of a feature. By combining the default install level for a feature with entries in the Condition table, you can create one installation that can be used by multiple groups of users who want different features in their application.

If you are using a dialog where the end-user has to enter information for certain feature(s) to install the following steps will also be necessary.

1. From Setup Editor >>Dialogs go to the Dialog where the user enters the information that will determine which feature gets installed.
2. Double click on the button that moves the installation to the Next action (Next or Enter...)
3. Select the Events tab, and Add an new event.
4. For the Action add DoAction, For the Argument enter CostFinalize 
    For  the Condition enter 1.