Setup Factory for Windows Installer

Conditions

Conditions are text expressions that get evaluated by Windows Installer during the installation in order to make things conditional. Conditions are usually based on the value of a property.

Some examples of where you can define conditions are:

Components - to decide whether a component will be processed

Conditional Levels - to override the default level of a feature

Launch Conditions - to decide whether the installation can begin

Note that in order to place a condition on a file (to control whether it's installed) or an action (to control whether it's performed) you must place the condition on the component that contains it. The decision about whether to install a file or perform an action happens at the component level.

Conditions permit whatever they're associated with when they are true, and prevent it when they are false.

The simplest condition consists of the name of a property, and simply tests whether that property is defined.

For example, the following condition:

AdminUser

...would only be true when AdminUser is defined. (The AdminUser property is defined when the user has administrative privileges.)

More complex conditions can be formed using expressions. An expression is a condition that compares the value of a property to some other value, in which case the condition will be true if the result of the comparison is true.

For example, the following condition:

PhysicalMemory > 512

...would only be true if PhysicalMemory contains a value larger than 512. (The PhysicalMemory property contains the amount of RAM installed in the user's system, in megabytes.)

Please see the Conditional Statement Syntax topic in the Microsoft Developer Network for details about how to form such conditional expressions.

Examples:

Version9X

...will be true if the property Version9X is defined, which means the user is running Windows 95, 98, or ME.

NOT AdminUser

...will be true only if AdminUser is not defined, which means the user does not have administrative privileges.

NOT Installed

...will be true only if the product is not already installed, i.e. this is a "full" install and not a Repair or Modify install.

Installed

...will be true only if a "maintenance" installation is being performed.

REMOVE="ALL"

...will be true only if an uninstall is being performed. (Note that this condition is only valid after InstallValidate, since that is when the REMOVE property is set.)

VersionNT = 501

...will be true only if Windows XP is installed. Whenever an NT operating system is installed, the VersionNT property is assigned a numeric value that represents the OS version using the following formula: (MajorVersion * 100) + MinorVersion.

Version9X = 410 AND (WindowsBuild >= 2222)

...will be true only if Windows 98 SE is installed.

ScreenX >= 800 AND ScreenY >= 600

...will be true only if the user's screen resolution is 800x600 or greater.

VersionNT = 501 AND ServicePackLevel > 0

...will be true only if Windows XP with Service Pack 1 or newer is installed.

ProductName >< "Super"

...will be true only if the value of ProductName contains the substring "Super" in it.

USER_NAME = "Ted"

...performs a case-sensitive comparison between USER_NAME and "Ted", so it will be true if the value of USER_NAME is exactly "Ted" and nothing else.

USER_NAME ~= "Ted"

...performs a case-insensitive comparison between USER_NAME and "Ted", so it will be true if the value of USER_NAME contains TED, or ted, tED, TeD, etc.

More Information

WiX Help File: Condition Element

MSDN Online: Conditional Statement Syntax

MSDN Online: Examples of Conditional Statement Syntax

MSDN Online: Using Properties in Conditional Statements

MSDN Online: Condition Table

MSDN Online: Properties