MsiApplyPatch function

For each product listed by the patch package as eligible to receive the patch, the MsiApplyPatch function invokes an installation and sets the PATCH property to the path of the patch package.


UINT MsiApplyPatch(
  _In_ LPCTSTR     szPatchPackage,
  _In_ LPCTSTR     szInstallPackage,
  _In_ INSTALLTYPE eInstallType,
  _In_ LPCTSTR     szCommandLine


szPatchPackage [in]

A null-terminated string specifying the full path to the patch package.

szInstallPackage [in]

If eInstallType is set to INSTALLTYPE_NETWORK_IMAGE, this parameter is a null-terminated string that specifies a path to the product that is to be patched. The installer applies the patch to every eligible product listed in the patch package if szInstallPackage is set to null and eInstallType is set to INSTALLTYPE_DEFAULT.

If eInstallType is INSTALLTYPE_SINGLE_INSTANCE, the installer applies the patch to the product specified by szInstallPackage. In this case, other eligible products listed in the patch package are ignored and the szInstallPackage parameter contains the null-terminated string representing the product code of the instance to patch. This type of installation requires the installer running Windows Server 2003 or Windows XP.

eInstallType [in]

This parameter specifies the type of installation to patch.

Type of installationMeaning

Specifies an administrative installation. In this case, szInstallPackage must be set to a package path. A value of 1 for INSTALLTYPE_NETWORK_IMAGE sets this for an administrative installation.


Searches system for products to patch. In this case, szInstallPackage must be 0.


Patch the product specified by szInstallPackage. szInstallPackage is the product code of the instance to patch. This type of installation requires the installer running Windows Server 2003 or Windows XP with SP1. For more information see, Installing Multiple Instances of Products and Patches.


szCommandLine [in]

A null-terminated string that specifies command line property settings. See About Properties and Setting Public Property Values on the Command Line. See the Remarks section.

Return value


The function completed successfully.


Patch package could not be opened.


The patch package is invalid.


The patch package is unsupported.

An error relating to an action

See Error Codes.

Initialization Error

An initialization error occurred.



Because the list delimiter for transforms, sources, and patches is a semicolon, this character should not be used for file names or paths.


You must set the REINSTALL property on the command line when applying a small update or minor upgrade patch. Without this property, the patch is registered on the system but cannot update files. For patches that do not use a Custom Action Type 51 to automatically set the REINSTALL and REINSTALLMODE properties, the REINSTALL property must be explicitly set with the szCommandLine parameter. Set the REINSTALL property to list the features affected by the patch, or use a practical default setting of "REINSTALL=ALL". The default value of the REINSTALLMODE property is "omus". Beginning with Windows Installer version 3.0, the REINSTALL property is configured by the installer and does not need to be set on the command line.




Windows Installer 5.0 on Windows Server 2012, Windows 8, Windows Server 2008 R2 or Windows 7. Windows Installer 4.0 or Windows Installer 4.5 on Windows Server 2008 or Windows Vista. Windows Installer on Windows Server 2003 or Windows XP. See the Windows Installer Run-Time Requirements for information about the minimum Windows service pack that is required by a Windows Installer version.







Unicode and ANSI names

MsiApplyPatchW (Unicode) and MsiApplyPatchA (ANSI)

See also

Error Codes
Initialization Error
Multiple-Package Installations
Not Supported in Windows Installer 2.0 and earlier