How to control the installation process using Custom Actions
The following article uses options that are available starting with the Professional edition and project type.
A custom action can interact with an installing package through "Session objects". The Session object controls the installation process by opening the Installer database, which contains the installation tables and data.
The Session objects can be used only in VBScripts to control the install process.
The Session object defines the following members:
- Methods
- Properties
Methods
Method | Description |
---|---|
Execute custom action | Executes the specified action. |
EvaluateCondition | Evaluates a logical expression containing symbols and values and returns an integer of the enumeration msiEvaluateConditionErrorEnum. |
FeatureInfo | Returns an object containing descriptive information for the specified feature. |
FormatRecord | Returns a formatted string from template and record data. |
Message | Performs any enabled logging operations and defers execution to the UI handler object associated with the engine. |
Sequence | Opens a query on the specified table, ordering the actions by the numbers in the Sequence column. |
SetInstallLevel | Sets the install level for the current installation to a specified value and recalculates the Select and Installed states for all features. |
Syntax example:
Session.DoAction( action )
Properties
Property | Access type | Description |
---|---|---|
ComponentCosts | Read-only | Returns a RecordList object enumerating the disk space per drive required to install a component. |
ComponentCurrentState | Read-only | Returns the current installed state of the designated component. |
ComponentRequestState | Read-only | Obtains or requests a change in the Action state of a row in the Component table. |
Database | Read-only | Returns the database for the current installation session. |
FeatureCost | Read-only | Returns the total amount of disk space (in units of 512 bytes) required by the specified feature and its parent features (up to the root of the Feature table). |
FeatureCurrentState | Read-only | Returns the current installed state of the designated feature. |
FeatureRequestState | Read/write | Obtains or requests a change in the Select state of a feature's record and subrecords. |
FeatureValidStates | Read-only | Returns an integer representing bit flags with each relevant bit representing a valid installation state for the specified feature. |
Installer | Read-only | Returns the active installer object. |
Language | Read-only | Represents the numeric language identifier used by the current installation session. |
Mode | Read-only | This property is a value representing the designated mode flag for the current installation session. |
ProductProperty | Read-only | Represents the string value of a named installer property. |
Property | Read/write | Retrieves product properties from the product database. |
SourcePath | Read-only | Provides the full path to the designated folder on the source media or server image. |
TargetPath | Read/write | Provides the full path to the designated folder on the installation target drive. |
VerifyDiskSpace | Read-only | Returns true if enough disk space exists, and false if the disk is full. |
Syntax example:
propVal = Session.ComponentCosts
Obtain more information
For a complete description of the methods and properties, please visit the official MSDN site.
Examples
The following examples show how the Session objects can be used to control the install: