Sie sind auf Seite 1von 3

Summary of Conditional Statement Syntax

This table and the following list summarize the syntax to use in conditional expressions.

Item

Syntax

value

symbol | literal | integer

comparisonoperator

< | > | <= | >= | = | <>

term

value | value comparison-operator value | ( expression )|

Boolean-factor

term | NOT term

Boolean-term

Boolean-factor | Boolean-factor AND term

expression

Boolean-term | Boolean-term OR expression

symbol

property | %environment-variable | $component-action | ?component-state | &feature-action | !feature-state

Symbol names and values are case sensitive. Environment variable names are not case sensitive. Literal text must be enclosed between quotation marks ("text"). Note Literal text containing quotation marks cannot be used in conditional statements because there is no escape character for quotation marks inside literal text. To do a comparison against literal text containing quotation marks, the literal text should be put in a property. For example, to verify that the SERVERNAME property does not contain any quotation marks, define a property called QUOTES in the Property table with a value of " and change the condition to NOT SERVERNAME><QUOTES.

Nonexistent property values are treated as empty strings. Floating point numeric values are not supported.

Operators and precedence are the same as in the BASIC and SQL languages. Arithmetic operators are not supported. Parentheses can be used to override operator precedence. Operators are not case sensitive. For string comparisons, a tilde "~" prefixed to the operator performs a comparison that is not case sensitive. Comparison of an integer with a string or property value that cannot be converted to an integer is always msiEvaluateConditionFalse, except for the comparison operator "<>", which returns msiEvaluateConditionTrue.

Examples of Conditional Statement Syntax


Run action only if the product has not been installed.

NOT Installed
Run action only if the product will be installed local. Do not run action on a reinstallation.

(&FeatureName=3) AND NOT(!FeatureName=3)


The term "&FeatureName=3" means the action is to install the feature local. The term "NOT(!FeatureName=3)" means the feature is not installed local.

Run action only if the feature will be uninstalled.

(&FeatureName=2) AND (!FeatureName=3)


This condition only checks for a transition of the feature from an installed state of local to the absent state.

Run action only if the component was installed local, but is transitioning out of state.

(?ComponentName=3) AND ($ComponentName=2 OR $ComponentName=4)


The term "?ComponetName=3" means the component is installed local. The term "$ComponentName=2" means that the action state on the component is Absent. The term "$ComponentName=4" means that the action state on the component is run from source. Note that an action state of advertise is not valid for a component.

Run action only on the reinstallation of a component. ?ComponentName=$ComponentName

Run action only when a particular patch is applied. PATCH AND PATCH >< MEDIASRCPROPNAME

Conditioning Actions to Run During Removal


There are two ways to author the installation database such that an action is only called when the package is uninstalled:

If the action is sequenced after the InstallValidate action in the InstallExecuteSequence table, the package author may specify a condition of REMOVE="ALL" for the action in the Condition column. Note that the REMOVE property is not guaranteed to be set to ALL during an uninstall before the installer executes the InstallValidate action. Note that the quote marks around the value ALL are required in this case. If the action is sequenced after the CostFinalize action and any actions that could change the feature state, such as MigrateFeatureStates action, the action can be conditioned on the state of a particular feature or component. See Conditional Statement Syntax. Use this option to call an action during the removal of a particular feature or component, which may occur outside of the complete removal of the application.

Note that the Installed property can be used in conditional expressions to determine whether a product is installed per-computer or for the current user. To determine whether the product is installed for a different user, check the ProductState property. Note that older versions of a product may be removed during an upgrade by the RemoveExistingProducts action. The Upgrade table may also set the REMOVE property to ALL in this case. To determine whether a product is being removed by an upgrade, check theUPGRADINGPRODUCTCODE property. The installer only sets this property when RemoveExistingProducts removes the product. The installer does not set the property during a normal uninstall, such as removal with Add/Remove programs.

Das könnte Ihnen auch gefallen