Preventing an Old Package from Installing Over a Newer Version

Windows Installer upgrade packages can be authored to have major upgrades not install if a user already has a newer version installed. The procedure in this topic can only prevent downgrades that might be caused by running a major upgrade package. This procedure relies on the FindRelatedProducts Action, which only runs during a first-time installation and does not run in maintenance mode (reinstallation). Because minor upgrades are performed using reinstallation, this procedure cannot be used to determine whether a minor upgrade package is attempting to downgrade an application. For more information, see Preparing an Application for Future Major Upgrades.

To prevent an old package from installing over a newer version

  1. Enter the UpgradeCode Property for the group of related products that may be eligible to receive this upgrade into the UpgradeCode column of the Upgrade Table.

  2. Enter the msidbUpgradeAttributesOnlyDetect bit flag in the Attributes column of the Upgrade Table.

  3. Enter the version of the upgrade provided by this package into the VersionMin column of the Upgrade Table. Leave the VersionMax column blank.

  4. Enter the name of the property that is to be set by the FindRelatedProducts Action into the ActionProperty column of the Upgrade Table.

  5. Add the SecureCustomProperties property and the property named in the ActionProperty column of the Upgrade Table to the Property Table.

  6. Add a Custom Action Type 19 after the FindRelatedProducts action in the InstallExecuteSequence Table. Include a record in the CustomAction Table for this action and enter the text to be displayed in the Target column. The type 19 custom action is built into the installer, so there is no code to write.

  7. Enter the name of the ActionProperty into the Condition column of the record in InstallExecuteSequence Table that contains the Custom Action Type 19. This conditions the custom action to only be executed when the Upgrade Table detects that a newer version is already installed.

    For example, a Windows Installer package that upgrades a group of related products to version 3.0 may include the following records in its Upgrade, CustomAction, InstallExecuteSequence, and Property tables. All the related products in the group have the same UpgradeCode, but the installer does not install this upgrade package if a version later than 3.0 is already installed on the computer. In this case, the Installer presents an error message and the installation fails. The version 3.0 upgrade package installs over versions 1.0 and 2.0.

    Upgrade Table

    UpgradeCode VersionMin VersionMax Language Attributes Remove ActionProperty
    {E7BE6D45-49FF-4701-A17E-BDCC98CE180D} 3.0   msidbUpgradeAttributesOnlyDetect NEWPRODUCTFOUND
    {E7BE6D45-49FF-4701-A17E-BDCC98CE180D} 1.0 3.0 msidbUpgradeAttributesVersionMinInclusive UPGRADEFOUND


    CustomAction Table

    Action Type Source Target
    CA1 19 A higher upgrade is already installed.


    InstallExecuteSequence Table

    Action Condition Sequence
    FindRelatedProducts 200


    Property Table

    Property Value