Summary
Installation and Uninstallation Conditions
Synopsis
Basic MSI projects created with InstallShield are database-driven, and not script-driven. One feature of MSI databases is that there are sequence tables that define the order of actions and dialog boxes to be performed and displayed. This article describes how to define Windows Installer conditions that enable you to specify that an action should be performed only during a first-time installation, a complete uninstallation, or only when a specific feature is being installed.
Discussion
Instead of using an explicit script, Basic MSI setups determine the actions to perform and the order in which they will occur using sequence tables. In particular, the InstallUISequence and InstallExecuteSequence tables?the "User Interface" and "Execute" sequences?contain ordered lists of actions to perform during a normal installation (that is, an installation started by double-clicking an MSI database icon or by running the command
msiexec /i ProductName.msi).
When working with the MSI sequence tables, an important idea is that the same sequences are used for first-time installations and maintenance installations (including uninstallation); there is no separate "uninstallation sequence". Therefore, any custom actions you schedule
in the Installation sequences will by default run for both installation and uninstallation. The problem, of course, is that this behavior is undesirable for many custom actions, especially those involving launching or manipulating files installed by your installation.
To ensure an action runs only for a first-time installation, you can use the condition Not Installed. (Keep in mind that property names are case-sensitive. A common error is to mis-capitalize the property name as "Not INSTALLED"; because the all-uppercase property INSTALLED is typically undefined, the condition "Not INSTALLED" will always succeed.) The condition Not Installed is appropriate, for example, for a custom action that launches a
Readme file or the application being installed.
The Installed property is set if the current product is already installed, either as a permachine installation or a per-user installation for the current user. (Note that Windows Installer also defines a ProductState property, which additionally enables you to detect if the current product is installed for another user.) If you have a custom action that should run for any maintenance operation?modify, repair, or remove, but not a first-time installation?
you can use the condition Installed.
To detect a complete uninstallation, you can use the REMOVE property in a condition. The REMOVE property is set to a comma-separated list of features that are to be removed. During a complete uninstallation, REMOVE is set to the special string value ALL, and therefore you can use the condition REMOVE="ALL" to detect a complete uninstallation.
NOTE: This condition is valid only after the InstallValidate action in the InstallExecuteSequence table.)
Another option for detecting a complete uninstallation in the User Interface sequence is to use the _IsMaintenance property. The standard MaintenanceType dialog box offers Modify, Repair, and Remove radio buttons; the user's radio-button selection is stored in the _IsMaintenance property, with one of the values "Change", "Reinstall", or "Remove". In the User Interface sequence, then, you can give an action the condition _IsMaintenance="Remove", anywhere after the MaintenanceType dialog box. (Because_IsMaintenance is a private property?its name contains lowercase letters?its value will be reset when execution switches from the User Interface sequence to the Execute sequence, and therefore it cannot be used in the Execute sequence to detect the installation type.)
To summarize, you can use the following conditions to detect different installation modes:
- First-time installation: Not Installed
- Any maintenance type: Installed
- Uninstallation: REMOVE="ALL" (after InstallValidate)
Feature and Component Conditions
In addition to detecting different types of installation for the entire product, it can sometimes be useful to detect if a specific feature or component is being installed or removed. To support this, Windows Installer provides special syntax in MSI database fields that use the Condition data type, such as the Condition field of a record in any of the sequence tables.
The most commonly used type of feature condition is the "feature action" type, in which the expression &FeatureName is set to a numeric value indicating the operation to be performed on the feature called "FeatureName". The possible values for &FeatureName are the following (valid after the CostFinalize action):
-1 No action (feature unchanged)
- Feature advertised
- Feature not installed (uninstalled)
- Feature installed locally
- Feature installed to run from source
For example, to detect if the feature called "FeatureA" is selected to be installed locally, and that it wasn't already installed locally, you can use the condition &FeatureA=3. You can use this condition on an action in the sequence tables, or on a NewDialog control event on the Next button of (for example) the CustomSetup or SetupType dialog box.
Feature-action conditions enable you to determine if a feature's installation state is changing (in the example above, from "not installed" to "installed locally"). If you want to determine a feature's state, regardless of whether the feature's state is changing, you can use "feature state" conditions. Feature-state conditions use the form !FeatureName=n, where n is one of the values from the table above.
Similarly, Windows Installer defines component-action and component-state conditional syntax, respectively $ComponentName=n and ?ComponentName=n, where again n is one of the values from the table above.
Additional Considerations
Some additional considerations when working with installation and uninstallation are the
following:
- If the user performs a silent or limited-UI installation, Windows Installer carries out only the actions in the Execute sequence. Therefore, any actions placed in the User Interface sequence will be skipped, irrespective of any condition attached to them.
- Related to the previous note, if the user launches an uninstallation by clicking the Remove button on the Add/Remove Programs panel (in Windows 2000 or later), only the actions in the Execute sequence will be performed.
- Custom actions that launch documents or executables during a first-time installation are sometimes scheduled in the Execute sequence; however, a document's or executable's user interface is generally inappropriate for a silent installation. To ensure an action runs only during a full-UI installation, you can combine the conditions described in this article with a condition using the UILevel property. The UILevel property is set to 5 for a full-UI installation (with lower numeric values for silent, basic-UI, and reduced-UI installations), and therefore you can use a condition such as (Not Installed) And (UILevel=5) to detect a first-time installation running with a full user interface.
Additional Information
MSDN Conditional Statement Syntax.
Common Conditions PDF.
Setting Product Conditions
Related Articles
Kill 64bit Process During Installation/Uninstallation 8Number of Views There Is Not Enough Space on Drive C to Extract the Files 13Number of Views Launch Another Installation or Uninstallation from within an Installation 4Number of Views InstallShield Missing from AdminStudio Installation 5Number of Views Troubleshooting Data Installation And Uninstallation 21Number of Views
Hi, I am Reva - Ask me anything.
No new updates
Thanks for the feedback!
Your feedback has been saved.Rate this response:
Add Additional feedback ( Optional )
Are you sure you want to cancel
the case creation?
Are you sure you want to cancel the case creation?
Are you sure you want to close this case
| Products | Region | Phone Numbers |
|---|---|---|
| FlexNet Operations FlexNet Embedded FlexNet Publisher FlexNet Connect FlexNet Code Insight InstallAnywhere InstallShield |
North America * |
+1 630-332-2513 (toll) +1 877-279-2853 (toll-free in North America) |
| Europe * |
+44 1925 944367 (toll) +44 800 047 8642 (toll-free in Europe) |
|
| Japan * | +81 3-4540-5335 (select option 2) | |
| Australia * |
+61 3 9895 2177 +61 1800 560 603 (toll-free in Australia) |
|
|
Usage Intelligence (formerly
Revulytics) Compliance Intelligence |
Please use the Case Portal to submit your support ticket or reach out to your Revenera contact. | |
Case id: 00001065
Activity: Status change: 2 hours ago