Windows MSI File Clean Remove ProductName

Purpose
To cleanly remove an MSI installed item, save this as a file, then pass a reasonable part of the ProductName to it, to remove. See the example at the bottom for usage. It will remove multiple items if the partial ProuctName matches.


 * Relies on msizap.exe and msiinfo.exe [both from "Windows SDK Components for Windows Installer Developers"]
 * The great thing about this is you dont need to know the GID in advance. I developed this for removing Flash Player mainly. See the separate page about that as it does some other things too.

How it works
In a nutshell, it
 * 1) looks in the registry for a ProductName matching what you give it
 * 2) 'decyphers' the GID from the ProductCode
 * 3) runs the gid against msiexec to try and cleanly uninstall it
 * 4) runs the gid against msizap to remove what the above failed too
 * 5) finally tries to remove the registry keys that usually block a reinstall working if above two fail, these use the PackageCode and GID depending on where they are,
 * 6) then removes any remaining .msi files in the Windows Installer cache.

Example Usage
e.g. To remove a Microsoft C++ 2005 redistributable (any version).

Use quotes for the ProductName, it will match a partial string but words must be adjacent, e.g. ProductName-remove.bat "2005 Redistributable"

C:\>ProductName-remove.bat "2005 Redistributable" Requested ProductName 2005 Redistributable found Please wait, removing PackageCode:b25099274a207264182f8181add555d0 GID:{7299052b-02a4-4627-81f2-1818da5d550d} Removing associated Windows Installer files Finished processing 2005 Redistributable Please check the log: c:\Temp\2005 Redistributable-remove-log.txt for details Press any key to continue. ..