Understanding Windows Installer File Versioning rules


Article ID: 179979


Updated On:


Symantec Products




What do I need to know to understand Windows Installer File versioning rules?

When working with Windows Installer-based installations, knowing basic Windows Installer versioning rules helps predict how an .MSI should function on the destination computer. Because Windows Installer versioning rules work differently than most legacy script-based installation tools, understanding and using the Windows Installer rules can mean the difference between an installation that works and one that does not.

Controlling File Versioning Settings

Windows Installer provides a special property that controls the application of versioning rules to installation files. Setting the property REINSTALLMODE to various values affects how Windows Installer decides which files to replace and which to ignore during installation.

The default value of REINSTALLMODE is omus, which tells Windows Installer to replace only older files during installation. The REINSTALLMODE settings are made up of four letters explained in the following table:

  • O—Controls the file versioning rules and instructs Windows Installer to only replace lder files. The following flags control file replacement:
  • O—Replacesolder files
  • A—Replacesall files
  • E—Replacesfiles that have the same or older version number
  • P—Does not replace any existing files; only installs this file if the file doesn't previously exist
  • M—Rewrites Per-Machine registry keys
  • U—Rewrites Per-User registry keys
  • S—Re-creates shortcuts

Linking Multiple Files

Another way to control file installation is to link two or more files together as a unit and make the installation of those files depend on the versioning rules of one of the files in the group. For example, assume that your .MSI contains an .EXE and a .DLL. Because when the .EXE changes, the .DLL also changes, you want to group these files so when the .EXE installs, the .DLL installs regardless of the version information.

To do this, use a Windows Installer feature called Companion Files. In the File table of the .MSI, enter that name of the .EXE in the Version column. At installation time, Windows Installer, by using versioning rules, determines whether to install the .EXE. Based on those rules, Windows Installer installs or doesn't install the .EXE and .DLL files together regardless what the independent versioning rules on the .DLL would have normally decided.

Installing Versioned Files

As previously mentioned, REINSTALLMODE controls how versioned files install on the destination computer. For most versioned file installations, the following rules affect the installation:

  • When installing a versioned file over a non-versioned file, Windows Installer installs the versioned file regardless the time/date stamp.
  • When installing language-specific files, Windows Installer installs the file with the language code that matches the language code of the .MSI. Windows Installer evaluates this rule after comparing the file versions. If your .MSI contains a file that is version 1.2.3 and the destination computer contains an existing that is version 1.0.0, Windows Installer overwrites the 1.0.0 file in all cases except when the 1.0.0 file matches the language code of the .MSI and version 1.2.3 does not.
  • Windows Installer prefers files that contain multiple language codes to files that support one language.

Installing Non-Versioned Files:

Installing non-versioned files with Windows Installer differs from legacy script-based installation tools. Most users expect the file with the most recent date and time to be installed. However, Windows Installer does not use this method to determine non-versioned file installation and instead uses a two-step procedure.

First, Windows Installer compares the file's unique hash value generated for its content with the MsiFileHash table in the .MSI. If the hash values match, then Windows Installer determines the files are the same and does not replace the file on the destination computer.

If the hash values differ, Windows Installer compares the date/time stamp of the file on the computer. If the file's modification date is newer than its creation date, Windows Installer determines the file contains user-modified content and does not replace the existing file. To override this behavior, use companion files.

By understanding how Windows Installer handles different file-replacement scenarios, you can create a package that installs in a predictable manner. For more information about file versioning rules, see the topic titled File Versioning Rules in the Windows Installer SDK.