修补卸载自定义操作Patch Uninstall Custom Actions

你可以使用 " 自定义操作修补程序卸载" 选项 来指定仅当卸载修补程序时,安装程序才运行自定义操作。You can use the Custom Action Patch Uninstall option to specify that the installer run the custom action only when a patch is uninstalled.

Windows Installer 4.5 及更高版本: 你可以使用 " 自定义操作修补程序卸载" 选项 来指定安装程序在卸载修补程序时只运行自定义操作。Windows Installer 4.5 and later: You can use the Custom Action Patch Uninstall Option to specify that the installer only run the custom action when a patch is uninstalled.

**Windows Installer 4.0 及更早版本: * ***Windows Installer 4.0 and earlier: **

" 自定义操作修补程序卸载" 选项 不可用。The Custom Action Patch Uninstall option is not available. 由于安装程序不会应用要卸载的修补程序包,因此无法在修补程序包中标记要运行的 自定义操作There is no method for marking a custom action within a patch package to be run when the patch is uninstalled because the installer does not apply the patch packages being uninstalled.

若要在卸载特定修补程序时运行 自定义操作 ,则自定义操作必须存在于原始应用程序中,或者位于始终应用的产品的修补程序中。To have a custom action run when a particular patch is uninstalled, the custom action must either be present in the original application or be in a patch for the product that is always applied.

开发人员可以使用 MsiPatchRemovalList 属性创作 Windows Installer 包或修补程序,以执行 自定义操作 以删除修补程序。Developers can use the MsiPatchRemovalList property to author a Windows Installer package or patch that performs custom actions on the removal of a patch. 自定义操作可以创作到原始安装包、已应用于包的修补程序或不是 可卸载修补程序的修补程序。The custom action can be authored into the original installation package, a patch that has already been applied to the package, or a patch that is not an uninstallable patch. 自定义操作可以 conditionalized 在序列表的 MsiPatchRemovalList 属性上。The custom action can be conditionalized on the MsiPatchRemovalList property in the sequence tables. 有关 conditionalizing 操作的详细信息,请参阅 使用条件语句中的属性See Using Properties in Conditional Statements for more information about conditionalizing actions.

自定义操作可以从 MsiPatchRemovalList 属性的值获取要删除的修补程序的 guid。The custom action can obtain the GUIDs of patches being removed from the value of the MsiPatchRemovalList property. 自定义操作可以通过调用 修补程序对象MsiGetPatchInfoExPatchProperty属性来确定修补程序的安装状态是已应用、过时还是被取代。The custom action can determine whether the installation state of the patch is applied, obsolete, or superseded by calling the MsiGetPatchInfoEx or the PatchProperty property of the Patch object.

如果自定义操作需要修补程序的特殊元数据,修补程序应包含自定义操作,该操作会在应用修补程序时将元数据写入到注册表或文件位置。If the custom action requires special metadata from the patch, the patch should contain a custom action that writes the metadata to a registry or file location when the patch is applied. 原始应用程序中的自定义操作或始终应用的修补程序可以获取删除修补程序更改所需的信息。The custom action in the original application or a patch that is always applied can obtain the information needed to remove the patch's changes.

不应将进行不当修改的修补程序标记为 可卸载补丁Patches making changes that are difficult to undo correctly should not be marked as uninstallable patches.

修补程序排序Patch Sequencing

删除修补程序Removing Patches

可卸载修补程序Uninstallable Patches

卸载修补程序Uninstalling Patches

MSIPATCHREMOVEMSIPATCHREMOVE

MsiEnumapplicationsExMsiEnumapplicationsEx

MsiGetPatchInfoExMsiGetPatchInfoEx

MsiRemovePatchesMsiRemovePatches