Uninstalling MSI Packages Using Product ID GUID: Solutions Without MSI Files

Nov 23, 2025 · Programming · 18 views · 7.8

Keywords: Windows Installer | Product ID GUID | MSI Uninstallation | WiX Configuration | PowerShell Automation

Abstract: This technical paper provides an in-depth analysis of correctly uninstalling Windows Installer packages using Product ID GUIDs when the original MSI file is unavailable. Based on real-world WiX toolset cases, it examines common uninstallation errors, particularly the distinction between Product ID and Product Code, and offers comprehensive PowerShell automation solutions. The paper details Windows Installer's uninstallation mechanisms, including registry queries, WMI interfaces, and proper msiexec command syntax, delivering practical technical guidance for software deployment and maintenance.

Problem Background and Challenges

In software deployment automation, there is often a need to uninstall installed software packages without access to the original MSI installation files. Windows Installer provides the capability to uninstall using Product ID GUIDs, but various error messages are commonly encountered in practice. Typical errors include: "The installation package could not be opened. Verify that the package exists" and "This action is only valid for products that are currently installed".

Critical Issues with WiX Product ID Configuration

Analysis of WiX installation package source code reveals that the core issue lies in how Product IDs are configured. When explicitly specifying hardcoded GUIDs in WiX's Product element:

<Product Id='A4BFF20C-A21E-4720-88E5-79D5A5AEB2E8' ...>

The generated MSI file does not create a standard ProductCode property in the Property table, instead using a Product ID property. This prevents the system from correctly identifying the product code when using msiexec for uninstallation.

Solution: Auto-Generating Product Codes

The correct approach is to set the Product ID to '*' , allowing WiX to auto-generate the product code:

<Product Id='*' Language='2057' Manufacturer='COMPANYNAME IT-Operations' Name='COMPANYNAMEServerListener' Version='1.0.0' UpgradeCode='PUT-GUID-HERE'>

This configuration ensures the generated MSI file contains a standard ProductCode property, enabling successful uninstallation via GUID.

Correct Uninstall Command Syntax

With auto-generated product codes, the correct uninstall command is:

msiexec /x {generated-GUID}

Or using silent uninstall mode:

msiexec.exe /x "{588A9A11-1E20-4B91-8817-2D36ACBBBF9F}" /q

Note that the GUID must be enclosed in curly braces, and the product code must be accurate.

Methods for Finding Product Codes

In automation scripts, reliably obtaining GUIDs of installed products is essential. PowerShell WMI queries are recommended:

get-wmiobject Win32_Product | Format-Table IdentifyingNumber, Name

This method retrieves identifiers and names of all MSI products installed on the system, facilitating dynamic selection of products to uninstall within scripts.

Registry Query Approach

As an alternative method, product codes can be located through Windows Registry:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall

On 64-bit systems, 32-bit installed programs may reside under:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall

Complete PowerShell Automation Script

Combining the above techniques enables creation of comprehensive uninstallation automation scripts:

$products = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -like "*COMPANYNAMEServerListener*"} foreach ($product in $products) { $guid = $product.IdentifyingNumber Start-Process "msiexec.exe" -ArgumentList "/x $guid /qn" -Wait }

Technical Principle Analysis

During installation, Windows Installer registers product information in the system, including product codes, version information, and uninstall commands. When using the msiexec /x command, the system searches registered installation information for the corresponding product based on the provided GUID, then executes the uninstall routine stored within the system. This explains why original MSI files are not required for uninstallation.

Best Practice Recommendations

During software development, always use auto-generated product codes and avoid hardcoded GUIDs. Deployment scripts should include product verification logic to ensure only target products are uninstalled. For production environments, silent uninstall mode (/qn parameter) is recommended to prevent user interaction from disrupting automated processes.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.