Search code examples
windows-installer

What is an "installation script" in MSI?


Ofiicial Microsoft documentation refers some "installation script" in numerous places. Foe example, here:

Instead the installer writes the custom action into the installation script.

I have carefully examined MSDN and a few books about MSI - and can't find clear definition what is this installation script, how it's related to MSI engine and how it's exactly

installation script can be executed outside of the installation session in which it was written

Is it some definition and documentation about this installation script or it is some undocumented MSI engine internals that are referenced just for bibliographic purpose?


Solution

  • Windows Installer is a declarative (vs imperative) programming language. Instead of writing "script" in some language you use table data to express the installation. For example consider the tables:

    Feature -> Feature Components - Component -Directory

    Component -> File

    You are telling MSI that when a given feature is installed, the components that belong to it need to be installed. When the component is installed, a directory needs to be created and a file needs to be copied. If the installer rollsback, the file and directory needs to be removed.

    This is handled by various standard actions such as CreateFolders and InstallFiles. We don't write any script to accomplish this.

    But, there is in fact a script. It's generated by Windows Installer itself at runtime. Inside of any standard action that modifies machine state are two different phases:

    Script Generation - The installer is carefully considering what needs to be done and dynamically generating a list of operations to be performed

    Script Execution - The installer is now executing that script. Note: This occurs inside of InstallFinalize

    Log your favorite installer and start looking through it for the InstallFiles action. You'll see the two phases.

    This is very important stuff to realize when writing your own custom actions. For a lot more information on the subject, see:

    Installation Phases and In-Script Execution Options for Custom Actions in Windows Installer