MSI Report Generator
The VBscript file generates summary report of the MSI with list of files, ProductName, UpgradeCode, ProductCode, PackageCode, ProductVersion, ComponentCode their related component GUIDs, File Name, File Version, Install Condition if any.
This VBscript file allows the user to type in MSI path, a output report directory, a report name and exports data to a .bak which can be opened with notepad or Excel.
'*************************************************************'
' MSI_Report_Generator.vbs
'*************************************************************'
' This file accepts as input data:
' 1) the complete path to an MSI file
' 2) an output folder
' 3) an output file name
'
' This file then generates a TAB-delimited file
' listing the MSI files pertinent data:
' 1) Product Name
' 2) Upgrade Code
' 3) Product Code
' 4) Package Code
' 5) Product Version
' For each product component
' 1) Component code
' 2) File Name
' 3) File Version
' 4) Component Condition
'
' The extension of this output file is .BAK
' A .BAK file can be opened in MS Excel, and saved as a XLS report
'
'
'**********************************************************************'
'**********************************************************************'
' DECLARATIONS
'**********************************************************************'
Option Explicit
Dim FS, TS, WI, DB, View
Dim ProductName, ProductCode, UpgradeCode, PackageCode
Dim ProductVersion, record
Dim Total
Dim Path_MSI_File, Path_Result_Folder, Report_Name,Path_Result_File
Set WI = CreateObject("WindowsInstaller.Installer")
Path_MSI_File = " "
Set FS = CreateObject("Scripting.FileSystemObject"):CheckError
Do 'ACCEPT INPUT UNTIL USER PRESSES CANCEL or X
Do 'ACCEPT PATH TO MSI FILE
Path_MSI_File = InputBox( _
"Please type in the complete path to the MSI for report generation." _
+ vbNewLine + vbNewLine + "Press Cancel or X to exit.", _
"C:\COMPLETE PATH TO MSI\My.MSI","C:\")
Loop Until ((FS.FileExists(Path_MSI_File) AND _
(FS.GetExtensionName(Path_MSI_File) = "MSI" OR FS.GetExtensionName(Path_MSI_File) = "msi" _
OR FS.GetExtensionName(Path_MSI_File) = "mSI" OR FS.GetExtensionName(Path_MSI_File) = "MSi" _
OR FS.GetExtensionName(Path_MSI_File) = "msI" OR FS.GetExtensionName(Path_MSI_File) = "mSi" _
OR FS.GetExtensionName(Path_MSI_File) = "MsI" OR FS.GetExtensionName(Path_MSI_File) = "Msi" _
)) OR Path_MSI_File = "")
If Path_MSI_File = "" Then Exit Do
Path_Result_Folder = InputBox("Please type in the path to the report generation output folder" _
+ vbNewLine + vbNewLine + "Last character must be a back-slash (\)." _
+ vbNewLine + vbNewLine + "Press Cancel or X to exit.", _
"C:\PATH TO REPORTS FOLDER\","C:\")
If Path_Result_Folder = "" Then Exit Do
If NOT (FS.FolderExists(Path_Result_Folder)) Then _
FS.CreateFolder(Path_Result_Folder)
Report_Name = InputBox("Please type in report's file name" _
+ vbNewLine + vbNewLine + "Do not type extension or trailing period (.)" _
+ vbNewLine + vbNewLine + "Press Cancel or X to exit.", _
"MsiReportName","File Name goes here")
If Report_Name = "" Then Exit Do
Path_Result_File = PAth_Result_Folder & Report_Name & ".bak"
Set DB = WI.OpenDatabase(Path_MSI_File,0)
PackageCode = DB.SummaryInformation.Property(9)
Set View = DB.OpenView("Select `Value` From Property WHERE `Property`='ProductName'")
View.Execute
Set ProductName = View.Fetch
Set View = DB.OpenView("Select `Value` From Property WHERE `Property`='UpgradeCode'")
View.Execute
Set UpgradeCode = View.Fetch
Set View = DB.OpenView("Select `Value` From Property WHERE `Property`='ProductCode'")
View.Execute
Set ProductCode = View.Fetch
Set View = DB.OpenView("Select `Value` From Property WHERE `Property`='ProductVersion'")
View.Execute
Set ProductVersion = View.Fetch
If Not ProductName Is Nothing Then
Set TS = FS.CreateTextFile(Path_Result_File):CheckError
' Write Product Column Headings to Text File
TS.Write vbNewLine
TS.Write "ProductName" + vbTab
TS.Write "UpgradeCode" + vbTab
TS.Write "ProductCode" + vbTab
TS.Write "PackageCode" + vbTab
TS.Write "ProductVersion" + vbTab
TS.Write vbNewLine
' Write Data to Text File
TS.Write ProductName.StringData(1)
TS.Write vbTab
TS.Write UpgradeCode.StringData(1)
TS.Write vbTab
TS.Write ProductCode.StringData(1)
TS.Write vbTab
TS.Write PackageCode
TS.Write vbTab
TS.Write ProductVersion.StringData(1)
TS.Write vbNewLine
TS.Write vbNewLine
End If
' Write Component Column Headings to Text File
Total = 0
TS.Write "ComponentCode" + vbTab
TS.Write "File Name" + vbTab
TS.Write "File Version" + vbTab
TS.Write "Install Condition" + vbTab
TS.Write vbNewLine
TS.Write vbNewLine
Set View = DB.OpenView("SELECT `Component`.`ComponentId`,`File`.`FileName`,`File`.`Version`" _
& ",`Component`.`Condition`" _
& " FROM `Component`,`File` WHERE `Component`.`Component` = `File`.`Component_`"):CheckError
View.Execute
Do
Set record = View.Fetch : CheckError
If record Is Nothing Then Exit Do
Total = Total + 1
' Write Component Data to Text File
TS.Write vbNewLine
TS.Write record.StringData(1)
TS.Write vbTab
TS.Write record.StringData(2)
TS.Write vbTab
TS.Write record.StringData(3)
TS.Write vbTab
TS.Write record.StringData(4)
Loop
View.Close()
TS.Close
Loop
Set WI = Nothing
Sub CheckError
Dim message, errRec
If Err = 0 Then Exit Sub
message = Err.Source & " " & Hex(Err) & ": " & Err.Description
If Not installer Is Nothing Then
Set errRec = installer.LastErrorRecord
If Not errRec Is Nothing Then message = message & vbLf & errRec.FormatText
End If
Fail message
End Sub
Sub Fail(message)
Wscript.Echo message
Wscript.Quit 2
End Sub
'****************The End of Code********************'
Thanks,
Sid
| License: | AJSL By clicking the download link below, you agree to the terms and conditions in the Altiris Juice Software License |
| Support: | User-contributed tools on the Juice are not supported by Altiris Technical Support. If you have questions about a tool, please communicate directly with the author by visiting their profile page and clicking the 'contact' tab. |
