How can I list the GUID of an installed program in Windows? Alternatively, is it easier to find the GUID if I have the MSI file?
I'm looking through the MSI file with Orca but not sure where to look to find the GUID.
Thanks!
Typically (though not universally) if a piece of software uses MSI-based installation the GUID can be found in the Uninstall entry. It will usually either be the key name or will appear in the UninstallString and/or UninstallPath value. Sometimes life is easy and there is a ProductGuid value.
If you have access to the MSI, then probably the easiest way to find the ProductCode is by opening an MSI editor tool and heading to the Property table. There, you will find the ProductCode property, which gives you the unique identifier of that Windows Installer package.
All you need to do is navigate to the target . msi file in Windows Explorer, right-click that file, and select the Info option.
if you just want to know what ProductName and ProductCode (ProductId) a given MSI contains, without installing that MSI and checking the registry, you can query the MSI itself with PowerShell using a function like this (inspired by http://www.scconfigmgr.com/2014/08/22/how-to-get-msi-file-information-with-powershell):
function Get-MSIProperties {
param (
[Parameter(Mandatory=$true)]
[ValidateNotNullOrEmpty()]
[System.IO.FileInfo] $path,
[string[]] $properties = @('ProductCode', 'ProductVersion', 'ProductName', 'Manufacturer', 'ProductLanguage')
)
begin {
$windowsInstaller = (New-Object -ComObject WindowsInstaller.Installer)
}
process {
$table = @{}
$msi = $windowsInstaller.GetType().InvokeMember('OpenDatabase', 'InvokeMethod', $null, $windowsInstaller, @($Path.FullName, 0))
foreach ($property in $properties) {
try {
$view = $msi.GetType().InvokeMember('OpenView', 'InvokeMethod', $null, $msi, ("SELECT Value FROM Property WHERE Property = '$($property)'"))
$view.GetType().InvokeMember('Execute', 'InvokeMethod', $null, $view, $null)
$record = $view.GetType().InvokeMember('Fetch', 'InvokeMethod', $null, $view, $null)
$table.add($property, $record.GetType().InvokeMember('StringData', 'GetProperty', $null, $record, 1))
}
catch {
$table.add($property, $null)
}
}
$msi.GetType().InvokeMember('Commit', 'InvokeMethod', $null, $msi, $null)
$view.GetType().InvokeMember('Close', 'InvokeMethod', $null, $view, $null)
$msi = $null
$view = $null
return $table
}
end {
[System.Runtime.Interopservices.Marshal]::ReleaseComObject($windowsInstaller) | Out-Null
[System.GC]::Collect()
}
}
The three main GUIDs of a Windows Installer database are the Package Code, ProductCode, and UpgradeCode. The first is stored in the summary information stream (View menu in Orca), and the others are stored in the Property table. (Other forms of databases such as merge modules and patches have similar GUIDs in similar places, such as the merge module's GUID or the patch code GUID - each stored identically to the package code.)
To find them on a machine, you can look in the Uninstall key, where the ProductCode is often used. Or better yet, if you are looking to enumerate what is currently installed on the machine, you can call MsiEnumProducts.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With