问题
I can get the ProductCode
from the \Uninstall
and other Registry keys, but I dont see a specific PackageCode
listing.
Is there any way to reliably get a list of package codes for MSI's that have been installed? Opening each MSI is not preferred, but only for performance reasons.
回答1:
Please find below a VBScript to retrieve MSI information of various kinds, including package code.
Create a VBScript file on desktop and paste the below code. Run the script from desktop and look for the file msiinfo.csv
that gets created. Open this in Excel or equivalent and import the comma separated file for proper viewing.
Set fso = CreateObject("Scripting.FileSystemObject")
Set output = fso.CreateTextFile("msiinfo.csv", True, True)
Set installer = CreateObject("WindowsInstaller.Installer")
On Error Resume Next ' we ignore all errors
' Write headers
output.writeline ("ProductName" & ", " & "Version" & ", " & "ProductCode" & ", " & "PackageCode")
For Each product In installer.ProductsEx("", "", 7)
name = product.InstallProperty("ProductName")
version=product.InstallProperty("VersionString")
productcode = product.ProductCode
packagecode=product.InstallProperty("PackageCode")
output.writeline (name & ", " & version & ", " & productcode & ", " & packagecode )
Next
output.Close
回答2:
Package codes are really only of use to MSI so MSI doesn't expose much about them. Product codes already uniquely identify an installed product so given a product code, you can use MsiGetProductInfoEx
with INSTALLPROPERTY_PACKAGECODE
to get the product's package code.
回答3:
You can find a PackageCode value inside HKEY_CLASSES_ROOT\Installer\Products{PRODUCT_CODE_IN_COMPRESSED_GUID_FORMAT}.
Just note that the PackageCode string value will be in a Compressed GUID format as well (the GUID with no dash and "reversed"), so if you compare that value with the one from the MSI file (using SuperOrca for example) they may not match due to display formatting.
来源:https://stackoverflow.com/questions/33546619/is-the-packagecode-for-an-msi-stored-anywhere-in-windows