大网数据广告活动
安装更新与部署

Prevent an Old Package from Installing Over a Newer Version

· 52CE 我爱测

Windows Installer upgrade packages can be authored to have major upgrades not install if a user already has a newer version installed.

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
    CA1 NEWPRODUCTFOUND 201

    Property Table

    Property Value
    SecureCustomProperties NEWPRODUCTFOUND;UPGRADEFOUND

Source: Microsoft Learn / Windows Win32 documentation by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / Windows Win32 documentation
适用范围
Windows Win32 API · Source date 05/31/2018
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。