Extracting MSI File Names And Their Versions To Excel

 

This Vbs will send the file names and their version numbers contained in an MSI file to excel to help document the contents of your MSI packages.

 

Note:  You must include the full path to the Msi file if using the input box as in:

 

C:\Windows\System32\AdminPak.Msi.

 

If you prefer to specify the Msi file path within the script comment out the line that reads:

 

strMsiFile = InputBox ("Enter Msi File Name")

 

And add the line:

 

strMsiFile = "C:\Windows\System32\Adminpak.Msi"

 

Vbs Script:

 

Set objExcel = CreateObject("Excel.Application")

objExcel.Visible = True

objExcel.Workbooks.Add

intRow = 2

 

strMsiFile = InputBox ("Enter Msi File Name")

 

objExcel.Cells(1, 1).Value = "File Name"

objExcel.Cells(1, 2).Value = "File Version"

 

Set objInstaller = CreateObject("WindowsInstaller.Installer")

Set objDatabase = objInstaller.OpenDatabase(strMsiFile, 0)

 

objQuery = "Select FileName, Version From File"

Set MsiFile = objDatabase.OpenView(objQuery)

MsiFile.Execute()

 

Set MSIrecords = MsiFile.Fetch

Do While Err.number = 0

On Error Resume Next

 

objExcel.Cells(intRow, 1).Value = MSIrecords.StringData (1)

objExcel.Cells(intRow, 2).Value = MSIrecords.StringData (2)

 

Set MSIrecords = MsiFile.Fetch

intRow = intRow + 1

Loop

Error.Clear

 

objExcel.Range("A1:B1").Select

objExcel.Selection.Interior.ColorIndex = 19

objExcel.Selection.Font.ColorIndex = 11

objExcel.Selection.Font.Bold = True

objExcel.Cells.EntireColumn.AutoFit

 

MsiFile.Close

MsgBox "Done"

 

Published Friday, December 22, 2006 1:13 PM by dhite
Filed under:

Comments

No Comments