How to control the installation process using Custom Actions

ImportantThe 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.

TipThe Session objects can be used only in VBScripts to control the install process.

The Session object defines the following members:

  • Methods
  • Properties

Methods

MethodDescription
Execute custom action Executes the specified action.
EvaluateCondition Evaluates a logical expression containing symbols and values and returns an integer of the enumeration msiEvaluateConditionErrorEnum.
FeatureInfoReturns an object containing descriptive information for the specified feature.
FormatRecordReturns a formatted string from template and record data.
MessagePerforms any enabled logging operations and defers execution to the UI handler object associated with the engine.
SequenceOpens a query on the specified table, ordering the actions by the numbers in the Sequence column.
SetInstallLevelSets 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

PropertyAccess typeDescription
ComponentCostsRead-onlyReturns a RecordList object enumerating the disk space per drive required to install a component.
ComponentCurrentStateRead-onlyReturns the current installed state of the designated component.
ComponentRequestStateRead-onlyObtains or requests a change in the Action state of a row in the Component table.
DatabaseRead-onlyReturns the database for the current installation session.
FeatureCostRead-onlyReturns 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).
FeatureCurrentStateRead-onlyReturns the current installed state of the designated feature.
FeatureRequestStateRead/writeObtains or requests a change in the Select state of a feature's record and subrecords.
FeatureValidStatesRead-onlyReturns an integer representing bit flags with each relevant bit representing a valid installation state for the specified feature.
InstallerRead-onlyReturns the active installer object.
LanguageRead-onlyRepresents the numeric language identifier used by the current installation session.
ModeRead-onlyThis property is a value representing the designated mode flag for the current installation session.
ProductPropertyRead-onlyRepresents the string value of a named installer property.
PropertyRead/writeRetrieves product properties from the product database.
SourcePathRead-onlyProvides the full path to the designated folder on the source media or server image.
TargetPathRead/writeProvides the full path to the designated folder on the installation target drive.
VerifyDiskSpaceRead-onlyReturns 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: