Removing Patches

Beginning with Windows Installer version 3.0, it is possible to create and install patches that can be uninstalled singly, and in any order, without having to uninstall and reinstall the entire application and other patches. Windows Installer 3.0 also enables Patch Packages to be authored with a MsiPatchSequence Table that contains patch sequencing information. With versions of Windows Installer earlier than Windows Installer 3.0, the only method to remove particular patches from an application is to uninstall the entire patched application and then reinstall without reapplying any patches being removed.

Whether a patch can be uninstalled depends upon how the patch was authored, the version of Windows Installer used to install the patch, and the changes made by the patch to the application. If a patch is not uninstallable, then the only way to remove the patch is to uninstall the entire application and reinstall without applying the patch being removed.

You can uninstall one or more patches using a command line option, the scripting interface, or by calling MsiRemovePatches from another application. See Uninstalling Patches for more information about how to uninstall patches.

The value of the MSIPATCHREMOVE property lists the patches to be uninstalled. For each patch in the list, the installer verifies that the patch is uninstallable. If the user does not have privileges to remove the patch, the patch is unknown for the product, patch policy prevents removal, or the patch was marked as not uninstallable, the installer returns an error that indicates a failed installation transaction. See Uninstallable Patches for more information about what determines whether a patch is not uninstallable.

Once the patch is verified as removable, the installer removes the patch from the patch application sequence. For more information about how Windows Installer 3.0 determines what sequence to use when applying patches see Sequencing Patches. Note that removing patches from the sequence can cause patches marked obsolete or superseded to become active.

All patches selected for removal are listed in the MsiPatchRemovalList property. This property is a private property that is set by the installer and can be used in conditional expressions or queried by custom actions. The property contains the list of patch code GUIDs of patches to be removed. A 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.

After a patch is removed the state of the application is the same as if the patch was never installed. If possible, the installer restricts the process to the subset of features affected by the patch being removed. The installer automatically sets the REINSTALL property to the list of affected features. Files that were added by the patch are removed and files that were modified by the patch are overwritten. Files and registry entries are restored to the version expected by the product minus the patch. Features and components that were added by the patch are unregistered from the application. Note that additional content added by the patch can remain on the user's computer if the content is used by another patch that is still applicable.

If a file of a shared component is updated by a patch, the change affects all applications that share the component. When the patch is removed, again, the change affects all applications that share the component. This means that removal of a patch by one application can restore the file of the shared component to a lower version than required by another application. This could fix the first application, but cause the second application to stop working. In this case, the second application can be repaired by reinstalling the second application using the methods describe in Reinstalling a Feature or Application. This will restore the patched version of the file.

MsiEnumapplicationsEx

MsiGetPatchInfoEx

MSIPATCHREMOVE

MsiRemovePatches

Patch Sequencing

Patch Uninstall Custom Actions

Uninstallable Patches

Uninstalling Patches