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

Rollback Custom Actions

· 52CE 我爱测

When the installer processes the installation script, it simultaneously generates a rollback script.

When the installer processes the installation script, it simultaneously generates a rollback script. In addition to the rollback script, the installer saves a copy of every file it deletes during the installation. These files are kept in a hidden system directory. Once the installation is complete, the rollback script and the saved files are deleted. If an installation is unsuccessful, the installer attempts to rollback the changes made during the installation and restore the original state of the computer.

Although custom actions that schedule system operations by inserting rows into database table are reversed by a rollback of the installation, custom actions that change the system directly, or that issue commands to other system services, cannot always be reversed by a rollback. A rollback custom action is an action that the installer executes only during an installation rollback, and its purpose is to reverse a custom action that has made changes to the system.

A rollback custom action is a type of deferred execution custom action, because its execution is deferred when it is invoked during the installation sequence. It differs from a regular deferred custom action in that it is only executed during a rollback. A rollback custom action must always precede the deferred custom action it rolls back in the action sequence. A rollback custom action should also handle the case where the deferred custom action is interrupted in the middle of execution. For example, if the user were to press the Cancel button while the custom action was executing.

Note that Rollback Custom Actions cannot run asynchronously. See Synchronous and Asynchronous Custom Actions.

The complement to a rollback custom action is a commit custom action. The installer executes a commit custom action during the installation sequence, copies the custom action into the rollback script, but does not execute the action during rollback.

Note that a rollback custom action may not be able to remove all of the changes made by commit custom actions. Although the installer writes both rollback and commit custom actions into the rollback script, commit custom actions only run after the installer has successfully processed the installation script. Commit custom actions are the first actions to run in the rollback script. If a commit custom action fails, the installer initiates rollback but can only rollback those operations already written to the rollback script. This means that depending on the commit custom action, a rollback may not be able to undo the changes made by the action. You can ignore failures in commit custom actions by authoring the custom action to ignore return codes.

When the installer runs a rollback custom action, the only mode parameter it will set is MSIRUNMODE_ROLLBACK. See MsiGetMode for a description of the run mode parameters.

A rollback custom action can be specified by adding an option flag to the Type field of the CustomAction table. See Custom Action In-Script Execution Options for the option flag designating a rollback custom action.

Rollback and commit custom actions do not run when rollback is disabled. If a package author requires these types of custom actions for proper installation, they should use the RollbackDisabled property in a condition that prevents the installation from continuing when rollback is disabled. For information on how to disable rollback see Rollback Installation (Windows Installer).

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)

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

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