How to re-cache an MSI file

Sometimes, installed MSIs fail to uninstall. There can be various reasons, but one of the most common ones is when a custom action fails.

'Error 1720: There is a problem with this Windows Installer package. A script required for this install to complete could not be run. Contact your support personnel or package vendor.

This could happen because the target script/exe is missing, or because the custom action script has an error in it, or due to a missing condition (maybe the custom action only had to run during the installation). What’s relevant is that the MSI will always try to run that custom action and probably fail.

The solution to this issue is editing the MSI and fixing the issue (disabling the custom action for uninstall, for example), and then re-caching it. This way, Windows Installer will use the new version. It’s important that the elements used for identification remain the same: ProductCode, PackageCode, ProductVersion and so on.

To re-cache an MSI, one might want to use the command line:

msiexec /fv "path_to_msi" <optional parameters>

However, the script below takes this further and goes through the following logic:
– It reads MSI info from the MSI file (ProductCode, PackageCode)
– It checks if a product with the corresponding ProductCode is installed
– If Yes, it retrieves the PackageCode and if it’s the same as the one we’re trying to re-cache, then it actually re-caches the MSI

'The Script retrieves the PackageCode and ProductCode from the MSI file, then it searches (by ProductCode). 
'If the Product IS installed and the PackageCode is THE SAME, it recaches the MSI

Option Explicit

Const ERR_NOTFOUND = 2605
Const ERR_MSI = 2603 'general MSI io/query failure

'Create Objects, declare variables
dim installer
dim strProductCodeIn, strPackageCodeFound, strMsiFilePath, strLogFile, strPackageCodeIn
dim retCode, verFound, bStatus

retCode = 1

strMsiFilePath = wscript.arguments(0) 
strProductCodeIn = GetMsiProperty(strMsiFilePath, "ProductCode")
strPackageCodeIn = GetMsiPackageCode(strMsiFilePath)

strLogFile = wscript.arguments(1)
If  strProductCodeIn = "" Or strPackageCodeIn = "" Then wscript.quit(ERR_MSI)

' Check if Product Is Installed, by Checking PC
On error resume next
Set installer = Wscript.CreateObject("WindowsInstaller.Installer") 
strPackageCodeFound = installer.ProductInfo(strProductCodeIn,"PackageCode")

On error Goto 0
If strPackageCodeFound = "" then 
	bStatus = False
ElseIf strPackageCodeFound = strPackageCodeIn Then
	bStatus = True ' present
	dim strCmd, shell 
	Set shell = CreateObject("Wscript.Shell")
	strCmd = "msiexec /fv " & Chr(34) & strMsiFilePath & Chr(34) & " /norestart /qn REBOOT=ReallySuppress /L*v " & Chr(34) & strLogFile & Chr(34)
	retCode = shell.Run(strCmd, 0, True)
	'ProductCode foundversion found but cannot be replaced.
End If

Set installer = Nothing
wscript.quit retCode

Please feel free to use the script.

The extra functions can be found on the corresponding articles, here:


The exit codes of the script can be customized, of course.

How to retrieve the PackageCode from an MSI file programatically

In addition to our VBScript function that retrieves Property Values from an MSI database, we might need to read the PackageCode, from the MSI Summary view. For that, we could use the code below.

Function GetMsiPackageCode(msiFile)
	On Error Resume Next
	dim inst, summary, view, row, str
	str = ""
	set inst = Wscript.CreateObject("WindowsInstaller.Installer") 
	set summary = inst.SummaryInformation(msiFile)	
	If Err.number Then 
		str  =  summary.Property(9) ' PID_REVNUMBER = 9, package code.
	End If
	set summary = Nothing
	set inst = Nothing
	On Error Goto 0
	GetMsiPackageCode = str
End Function

To use it, we’d simply call GetMsiPackageCode(“C:\Temp\Test.msi”) and store it into a (string) variable.

How to retrieve Property Values from an MSI file, using VBScript

The VBScript function below can be used to retrieve MSI properties from an MSI file (database). It uses the WindowsInstaller.Installer class.

Function GetMsiProperty(msiFile, strProperty)
	On Error Resume Next
	dim inst, db, view, row, str
	str = ""
	set inst = Wscript.CreateObject("WindowsInstaller.Installer") 
	Set db = inst.OpenDatabase(msiFile,0)
	If Err.number Then 
		Set view = db.OpenView("Select `Value` From Property WHERE `Property` ='"& strProperty & "'")
		Set row = view.Fetch
		If Not row Is Nothing Then str=row.StringData(1)
	End If
	set row = Nothing
	set view = Nothing
	set db = Nothing
	set inst = Nothing
	On Error Goto 0
	GetMsiProperty = str
End Function

This function accepts the MSI full file path, and the property to be retrieved.

For example, in order to retrieve the ProductCode of an MSI whose full path is C:\Temp\Test.msi, one would call it like this:

strProductCode = GetMsiProperty("C:\Temp\Test.msi", "ProductCode")

If the property doesn’t exist, or if the file cannot be opened, the function will return an empty string “”.

SDBINST issues on Windows 7 and Windows 10

Possible Problems

When migrating packages Windows 7 (or older) to Windows 10, or when simply targeting multiple OS’s with the same package, one might to pay attention on the way SDBINST.exe is used for compatibility fixes (shims).
In case the executable is included in the package (simply as a file or in the binary table, inside an MSI), there could be issues like error exit codes of sdbinst, or worse, like an incorrect behaviour even though the SDB file would appear to be installed.

Long story short:

  • the SDBINST from Windows 7 will behave incorrectly on Windows 10 (shim/sdb will appear as installed but won’t do what it’s supposed to do)
  • the SDBINST.exe from Windows 10 will not work at all on Windows 7 (visible in the exit code)



Adapt the package so that SDBINST.exe is excluded from it and use the executable found on the system, whether it’s an Win7 or Win10 OS.

In case this is done inside an MSI via custom action, make sure to change it from “Execute from Installation” in Wise or “EXE – Stored in Binary Table/Installed with Product” in InstallShiled to “Execute from Destination” – Wise or “EXE – Path from Directory”. That will result in a custom action with type 3106 (0x0c22) if you’re executing in Deferred – System Context, Synchronous.


More info

For more info on sdbinst.exe and how to use it, check our other post about this topic.



MSI error 1624

1624 (ERROR_INSTALL_TRANSFORM_FAILURE) is a Windows Installer error related to transforms.

Possible causes (but not exclusive):

  • MST file is missing (or misspelled)
  • MST file is not valid (mst internal errors)
  • MST file is corrupted


  • Make sure the command line points to the correct location of the MST and that the name is correct
  • Check for MST internal errors if you’ve edited it yourself
  • Try to redownload the MST file, in case it might be corrupted

MSI error 1620

The error 1620 (ERROR_INSTALL_PACKAGE_INVALID) of msiexec occurs when the package being installed is an invalid MSI. This can be caused by the corruption of the MSI file. In order to fix this, please try to copy or download again the file from its original source.

Note: This is not caused by an internal error of the MSI database.

MSI error 1619

The error 1619 (ERROR_INSTALL_PACKAGE_OPEN_FAILED) has an obvious cause: the MSI (or MSP) cannot be read. This problem can have different causes:

  • The file is missing. Try checking if the file is present in the specified location.
  • The package (MSI or MSP) cannot be read due to Security. Check security settings, make sure SYSTEM (or the user that launches MSIEXEC) has at least Read permissions.
  • The file cannot be read because another process locks it for editing. Some tools, such as Orca, open MSI files in exclusive mode. To solve this, close the process that locks it (Orca, in our example) and retry the installation.

MSI error 1618

The meaning of an exit value of 1618 of msiexec is ERROR_INSTALL_ALREADY_RUNNING. It’s one of the most common codes of Windows Installer (after 1603, of course).
This happens if an installation started while another one was already running. It doesn’t affect the first one, but it won’t do anything. There cannot be two instances of msiexec running at the same time.

The solutions for this issue are the following:

  1. Wait for the first installation to end, then start the second one.
  2. If you need to automate this in a wrapper, you can check if there’s an installation in progress and wait for it to end. Check for msiexec /i or msiexec /x or msiexec /<something> using pv.
  3. (not recommended) If you think that the installation in progress is hanging and should be stopped(or something similar), you can try to end it, by killing the running msiexec.exe instances.
  4. (not recommended) Reboot the machine. This will kill any installation in progress.  Then try again.
  5. mentions 3 extra solutions to the problem. Ont might want to check those as well, if the ones presented above haven’t solved the issue.

How to Apply a Patch to an Administrative Install

Let’s suppose we have an MSI called setup.msi and a patch for it, called patch.msp
If we want both the setup and the patch to be installed we have two options.

Option #1
Install both separately:
1. Install setup: msiexec /i setup.msi [...other params]
2. Install the patch: msiexec /p patch.msp [...other params]

Option #2
Install the patched MSI at once.

We well explain here the second option.

1. First, we need to create the administrative installation (setup.msi)

Run: msiexec /a path_to_setup\setup.msi TARGETDIR=folder_for_admin_install
In the folder you’ve defined as folder_for_admin_install, we can find setup.msi and the extracted files..

2. Then, we`ll apply the patch:
Copy the patch.msp to the same folder as the admin install (not mandatory, but recommended)
BackUp the existing setup.msi, for it will be altered.

Run: msiexec /a folder_for_admin_install\setup.msi /p folder_for_admin_install

This will create a new MSI (+side files) that includes the old msi+the patch. It will replace the previous setup.msi. Voila, done!

Error codes for Windows Installer

We’re presenting below a list of exit codes that msiexec.exe returns and, in some cases, what to do to fix them.


In bold, you`ll find the ones you’ll encounter the most.

Value returned
Error code
Error description
Action completed successfully.
Nothing to be done
The data is invalid
One of the parameters was invalid.
The Windows Installer service could not be accessed. Contact your support personnel to verify that the Windows Installer service is properly registered.
There’s a problem with the Windows Installer Service. It might happen after a KB that affects it has just been installed. Solution: Restarting the machine usually solves the problem.
User cancel installation.
The user has cancelled the installation. Solution: just don’t cancel it 🙂
Fatal error during installation.
It’s the most common error code. It means something is wrong with the package.
Installation suspended, incomplete.
This action is only valid for products that are currently installed.
This happens when you try to uninstall/repair an MSI using its product code. Solution: Check if the product is installed first. For example, the existance of HKCR\Installer\Products\hash corresponding key
Feature ID not registered.
Component ID not registered.
Unknown property.
Handle is in an invalid state.
The configuration data for this product is corrupted. Contact your support personnel.
Component qualifier not present.
The installation source for this product is not available. Verify that the source exists and that you can access it.
This installation package cannot be installed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service.
Product is uninstalled.
SQL query syntax invalid or unsupported.
Record field does not exist.
Another installation is already in progress. Complete that installation before proceeding with this install.
This happens when you try to install a product while another installation is in progress. Solution: Wait until the previous installation is finished. More info here.
This installation package could not be opened. Verify that the package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer package.
Either the file (MSI) doesn’t exist, or it’s being locked for editing (by tools such as Orca, insted, etc). Solution: Check the location and make sure no process holds it locked. More info here.
This installation package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer package.
More info here
There was an error starting the Windows Installer service user interface. Contact your support personnel.
Error opening installation log file. Verify that the specified log file location exists and is writable.
Solution: Make sure you have the permissions to write to the log file. Or change its location.
This language of this installation package is not supported by your system.
Error applying transforms. Verify that the specified transform paths are valid.
More info about the error, as well as solutions, on the dedicated page.
This installation is forbidden by system policy. Contact your system administrator.
Function could not be executed.
Function failed during execution.
Invalid or unknown table specified.
Data supplied is of wrong type.
Data of this type is not supported.
The Windows Installer service failed to start. Contact your support personnel.
The temp folder is either full or inaccessible. Verify that the temp folder exists and that you can write to it.
This installation package is not supported on this platform. Contact your application vendor.
Component not used on this computer.
This patch package could not be opened. Verify that the patch package exists and that you can access it, or contact the application vendor to verify that this is a valid Windows Installer patch package.
This patch package could not be opened. Contact the application vendor to verify that this is a valid Windows Installer patch package.
This patch package cannot be processed by the Windows Installer service. You must install a Windows service pack that contains a newer version of the Windows Installer service.
Another version of this product is already installed. Installation of this version cannot continue. To configure or remove the existing version of this product, use Add/Remove Programs in Control Panel.
Invalid command line argument. Consult the Windows Installer SDK for detailed command line help.
Installation from a Terminal Server client session not permitted for current user.
The installer has started a reboot.
The installer cannot install the upgrade patch because the program being upgraded may be missing, or the upgrade patch updates a different version of the program. Verify that the program to be upgraded exists on your computer and that you have the correct upgrade patch.
A restart is required to complete the install. This does not include installs where the ForceReboot action is run.