Want to find the GUID of an MSI installation
I want to be able to find out what the GUID will be for the uninstall string of an MSI package.
I want to do this without installing the package and since I have to do this for more than 100 MSIs a command line or data dump of an msi I can mine the data out of is preferred.
help?????
mike
Answers (5)
You can use something like this which I've quickly knowcked up. Paste it into a file, say uninstallString.vbs. Usage is:
Open a CMD prompt
Type: Cscript uninstallString.vbs <path to root folder containing all MSIs)
Things to do:
Error trapping
Write results to log file instead of CMD prompt
Retrieve Product Name?
The Script:
Set objFSO = CreateObject("Scripting.FileSystemObject")
'set this to the root folder which contains all the MSIs in subfolders
objStartFolder = wscript.arguments(0)
Set objFolder = objFSO.GetFolder(objStartFolder)
Set colFiles = objFolder.Files
For Each objFile in colFiles
wscript.echo objFile.Path
wscript.echo GetProductCode(objFile.Path)
Next
Wscript.Echo
ShowSubfolders objFSO.GetFolder(objStartFolder)
Sub ShowSubFolders(Folder)
For Each Subfolder in Folder.SubFolders
Set objFolder = objFSO.GetFolder(Subfolder.Path)
Set colFiles = objFolder.Files
For Each objFile in colFiles
wscript.echo objFile.Path
wscript.echo GetProductCode(objFile.Path)
Next
Wscript.Echo
ShowSubFolders Subfolder
Next
End Sub
Function GetProductCode(ByVal msiPath)
Const msiOpenDatabaseModeReadOnly = 0
Dim msi, db, view
Set msi = CreateObject("WindowsInstaller.Installer")
Set db = msi.OpenDataBase(msiPath, msiOpenDatabaseModeReadOnly)
Set view = db.OpenView("SELECT `Value` FROM `Property` WHERE `Property` = 'ProductCode'")
view.Execute()
GetProductCode = "MSIEXEC /X " & view.Fetch().StringData(1) & " /QN"
End Function
Comments:
-
I am no good at programming but I've changed the Function to display some more useful info if you want to use them for version checking etc:
Function GetProductCode(ByVal msiPath)
Const msiOpenDatabaseModeReadOnly = 0
Dim msi, db, prodcode, prodname, prodversion
Set msi = CreateObject("WindowsInstaller.Installer")
Set db = msi.OpenDataBase(msiPath, msiOpenDatabaseModeReadOnly)
Set prodcode = db.OpenView("SELECT `Value` FROM `Property` WHERE `Property` = 'ProductCode'")
Set prodname = db.OpenView("SELECT `Value` FROM `Property` WHERE `Property` = 'ProductName'")
Set prodversion = db.OpenView("SELECT `Value` FROM `Property` WHERE `Property` = 'ProductVersion'")
prodcode.Execute()
prodname.Execute()
prodversion.Execute()
GetProductCode = "Name " & prodname.Fetch().StringData(1) & " Version " & prodversion.Fetch().StringData(1) & " Uninstall string " & prodcode.Fetch().StringData(1)
End Function
I would like to be able to display if the MSI is 32 or 64bit only but I don't know how to determine that from the MSI. - csjjpm 10 years ago
I'm sure you could do it with a script, but what I usually do is look in the registry where the Add Remove Programs (ARP) data is at
HKEY_LOCAL_MACHINESOFTWAREMicrosoftWindowsCurrentVersionUninstall
Do a search from here for your software name or just browse through-- the subkey for each product is it's GUID (at least for all the MSI setups).
Comments:
-
I don't wan tot install the software - msimike1970 12 years ago
a VBScript will do it but for each MSI the script should be run on each MSI atleast once to get the GUID
Comments:
-
OK....how does the VB script do the work? Am I missing something simple here? - msimike1970 12 years ago
-
I know this is a bit old but if you MSIs are in c:\myinstallers then you do this
cscript uninstallstring.vbs c:\myinstallers
then it should list each MSI with its uninstall string - csjjpm 10 years ago