November 26, 2009

Windows Installer Overview

Windows Installer Service:
Windows Installer Service helps to install, modify and remove applications provided as MSI Package. The first Windows Installer version was 2.0 and it was released with Windows XP. The latest one is Windows Installer 5.0 released with Windows Server 2008 R2 & Windows 7.
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. This is user-interface part of the installation
  • Execution: During the execution phase, the installer passes the information to a process with elevated privileges and runs the script. This is the execution part of the installation which actually modifies the system.
Features of Windows Installer:

  • Rollback: WIS includes the computers’ pre-installation state in its database, so it can support complete installation rollbacks in the case of a problem during installation, returning the target system to the same state it was in before the installation began.
  • Repair: WIS stores the software configuration in its database and hence it can automatically repair an installation, when a problem occurs with the program. This repair mode can be run through a maintenance mode, but it is also automatically run each time a user launches a program through its shortcuts or through opening of a document generated by the program.
  • Elevation: In secured environments like Vista / Windows 7, the WIS, which is always running in the background, can automatically elevate a user’s privilege during installation to insure that the installation will occur properly in locked-down environments.
  • Resiliency: Resiliency is a program's ability to recover gracefully from situations in which a vital component is missing. By authoring an installation package and by using the Installer functions, developers can use Windows Installer to produce resilient programs that can recover from such situations.
    Resiliency can be turned ON or OFF for a file / registry key by specifying / removing the KeyPath value for each component.
    Click here for more information on resiliency.
  • Advertise: Advertised application can create shortcuts, registry keys, file association etc., without actually copying files to the target computer. The product will be installed by triggering the entry point (say by means of a Start menu shortcut, by opening a document that the product is configured to handle, or by invoking an advertised COM class). When advertised, the application will be installed as explained in Install on demand.
    Two types of advertising viz- Assigning & Publishing
    For assigned application, the user has an entry point like shortcut to activate the application on-demand.
    For published application, the user does not have an entry point to activate installation-on-demand and the application can be installed only if another application activates the published application.
  • Install on demand: Installation-on-demand makes it possible to offer functionality to users and applications in the absence of the files themselves. This notion is known as advertisement. The Windows Installer has the capability of advertising functionality and to make installation-on-demand of application features or entire products possible. When a user or application activates an advertised feature or product, the installer proceeds with installation of the needed components. This shortens the configuration process because additional functionality can be accessed without having to exit and rerun another setup procedure.
  • Remove / Retire: WIS can completely remove the application from system, as all the configurations are tracked in its database
Detect Windows Installer Version Installed:
There are three different ways in which you can detect the version of Windows Installer installed on your system.

  1. Using MSI.DLL
    Search MSI.DLL in Windows Folder, Locate the file, RightClick –> Properties -> Version Tab -> Product Version. 
  2. Getting Help on MSIEXEC
    Type msiexec /? Or msiexec /help on command prompt
  3. Scripting
    Create a VBS File – DisplayMSIVersion.vbs and type in the following code
    set installer = createobject("windowsinstaller.installer")
    msgbox "MSI Version - " & installer.version
    Save & Run to see the MSI Version
Windows Installer Architecture:


MSI consists of Installation instructions and Software parts to be installed i.e. usually .cab files within or along with MSI
MSI contains an installation database (relational) that WIS uses to perform installation
Product
  • highest level in hierarchy
  • Identified by Product code or Product GUID
Feature
  • Basic building block from end user’s perspective and it can have sub-features too.
  • Each item that can be selected or unselected for installation is a feature or sub-feature.
  • Features can be shared across applications.
  • WIS does not remove the shared feature until all the application using the shared feature is removed.
  • Example: Spell checker in Office, which is shared across Excel, Word Applications.
Component
  • Features are made up of components and it the basic building block from developer’s perspective.
  • Component has a unique GUID, which WIS uses to identify it within the installation database.
  • A component is a collection of files, registry keys, shortcuts, create / manage NT Services which are generally called as resources.
  • Component Rules: Component rules ensure that the authors of installation packages create packages that do not damage the components of other installations or leave resources after uninstall.
    • All files in a given component must be installed to the same directory. Conversely, files installed to separate folders must belong to separate components.
    • There can be only one key path per component
    • Any two resources that might ship separately in subsequent versions should exist in separate components. Resources should be grouped into the same component only when you are certain that these resources will never ship separately. Versioned resource should not be shipped in more than one component.
    • All primary resources (DLLs, EXEs, for example) always exist in separate.
    • Same file cannot be the key file in two different components which will go into a common feature.
Key Paths:
  • A key path is a specific file, registry key, or ODBC data source that the package author specifies as critical for a given component. Because a file is the most common type of key path, the term key file is commonly used.
  • A component can contain only one key path; if a component has no explicit key path, the component's destination directory is taken to be the key path. 
  • When an MSI-based application is launched, Windows Installer checks the existence of these critical files or registry keys (that is, the key paths). If there is a mismatch between the current system state and the value specified in the MSI package (e.g., a key file is missing), then the related feature is re-installed. This process is also known as self-healing or self-repair. 
  • No two components should use the same key path.

1 comment:

  1. Bhuvana,
    Great job. I am really happy to see your blog.I have added your page in my favorites list.
    Keep up the good work.

    Regards,
    Praveena.

    ReplyDelete