Pages

Windows Installer (MSI) Installation Mechanism



There are two phases to a successful installation process: acquisition and execution. If the installation is unsuccessful, a rollback phase may occur.

Acquisition
At the beginning of the acquisition phase, an application or a user instructs the installer to install a feature or an application.

The installer then progresses through the actions specified in the sequence tables of the installation database. These actions query the installation database and generate a script that gives a step-by-step procedure for performing the installation.

All actions from the UI sequence table and all actions from the beginning to the InstallFinalize action in the Execute sequence table are running during acquisition phase.  No changes to the system are done at this phase. 

Main tasks for acquisition phase are:

·        Installation is started up on the correct version of operating system, platform, etc (Launch Conditions).
·        Competitive upgrade is being installed on the system with competing product installed (Application Search).
·        License for licensed product is valid (Product Validation)
·        Selecting features to install (either through user interface or properties in the command line).
·        File Costing - making sure that target system has enough of available hard disk space to install the product.
·        Generating the installation script for the next phase.

Execution

During the execution phase, the installer passes the information to a process with elevated privileges and runs the script.

This process executes all actions from the script.  All changes to the system are done at this phase.  Depending on success or failure of the running installation script, the Execution phase will be completed by Rollback or Commit Phase.

When the Windows Installer processes the installation script for the installation of a product or application, it simultaneously generates a rollback script and saves a copy of every file deleted during the installation. These files are kept in a hidden system directory and are automatically deleted once the installation is successfully completed. If however the installation is unsuccessful, the installer automatically performs a rollback installation that returns the system to its original state.

Rollback

If an installation is unsuccessful, the installer restores the original state of the computer. When the installer processes the installation script it simultaneously generates a rollback script. In addition to the rollback script, the installer saves a copy of every file it deletes during the installation. These files are kept in a hidden, system directory. Once the installation is complete, the rollback script and the saved files are deleted.

Automatic rollback of an unsuccessful installation is the default behavior of the installer. To disable rollback during an installation use one of the following:
·        DISABLEROLLBACK Property
·        PROMPTROLLBACKCOST Property
·        DisableRollback Action
·        DisableRollback
·        EnableRollback ControlEvent
Whenever rollback is disabled, the installer sets the RollbackDisabled property.

Windows Installer accomplishes rollback by creating a rollback script. A rollback script is a file that contains a linear sequence of operations to perform, such as file and registry updates, configuration information updates, user interface notifications, and state information for other operations.

Each operation recorded in the rollback script is a direct response to an operation in the installation script.
Rollback scripts are stored in binary format. This improves efficiency, avoids the need for parsing the file, and discourages manual editing of the file.

Rollback script files (.RBS and .RBF) are backups of existing files. Files with an .RBS file extension are rollback script files, and files with an .RBF file extension are backups of existing files. Both are stored in hidden folders called Config.msi.

The Config.msi folders are created when the Msiexec.exe file starts copying from the installation point. The rollback script file (.RBS) is always stored in the Config.msi folder on the disk where the operating system is installed.

The .RBF files are stored in the Config.msi folder on the disk where the program that is being backed up currently resides. This is done so that there is no crossing of disks when the program files are being backed up. All rollback files and the Config.msi folders are deleted when the installation completes successfully.

Commit Phase
Commit Custom actions are executed upon successful completion of the installation script. If the InstallFinalize action is successful, the installer will then run any existing Commit Custom actions. The only mode parameter the installer sets in this case is MSIRUNMODE_COMMIT. 

Remember:   Acquisition phase is also known as Immediate phase when it comes to custom actions.  All Immediate custom actions are running in the context of the user performing the installation.  Immediate custom actions must not change the system.  Execution phase is also known as Deferred phase when it comes to custom actions.  Deferred custom actions usually run with elevated privileges unless they are not impersonated.  Impersonated deferred custom actions are running in the context of the user performing the installation.

No comments:

Post a Comment