Building Conditional Statements

InstallShield 2015

Project: This information applies to the following project types:

Basic MSI
DIM
InstallScript MSI
Merge Module
MSI Database
MSM Database
QuickPatch
Transform

A conditional statement is an expression that the Windows Installer can evaluate as True or False. Typically, conditional statements are used to perform some action or enable a component’s installation based on the value or existence of a property.

You can use operators similar to those in Visual Basic for comparative and logical operations. For more information, see Conditional Statement Syntax.

Tip: In the Components, Dialogs, Custom Actions and Sequences, and Custom Actions views of InstallShield, you can access the Condition Builder dialog box when you click the ellipsis button in the condition property to help you build conditional statements.

Important: When you click the OK button on this dialog box, InstallShield performs basic condition validation; however, you should still double-check that your condition statements evaluate to the expected outcome. For more information and example conditions, see Conditional Statement Syntax.

Examples

The following table provides examples of some conditional statements and explanations of how they can be used. Consult the Windows Installer Help Library for more information on Windows Installer properties and conditional expression operators.

Examples of Conditional Statements

Purpose

Syntax

To install a component only on machines that have the client version of Windows 7 and later, specify this expression for its Condition setting.

VersionNT>=601 And MsiNTProductType=1

To install a component only on Windows Server 2008 R2 and later domain controllers and servers, specify this expression for its Condition setting.

VersionNT>=601 And MsiNTProductType>1

To install a component only on Windows XP, specify the expression for its Condition setting.

VersionNT=501

Note: You can also use the ServicePackLevel and WindowsBuild properties to distinguish between different operating systems. For a list of values, see Operating System Property Values in the Windows Installer Help Library.

To install a component only on machines running Windows 7 or later, specify this expression for its Condition setting.

VersionNT>=601

To execute a custom action only if the product has not been installed, check the value of the Installed property with this condition.

Not Installed

To install a component only if the target system is using U.S. English as the default language, compare the value of the SystemLanguageID property to the language ID for U.S. English by using this component condition.

SystemLanguageID=1033

Note: Related properties include UserLanguageID (the default language for the current user) and ProductLanguage (the language being used for the setup program’s user interface).

To allow your product to be installed only if the screen resolution is a minimum of 1024 X 768, add this condition to the Install Condition setting in the General Information view.

ScreenX >= 1024 AND ScreenY >= 768

To allow your product to be installed only if the target system has at least 2 GB of RAM, add this condition to the Install Condition setting in the General Information view.

PhysicalMemory >= 2048

See Also