dcsimg

Export File List to Excel From MSI Using VBScript

By ServerWatch Staff (Send Email)
Posted Dec 7, 2000


by John Loomes

This script prompts for an MSI (Windows Installer) Package, and an output location. It then queries the File table within MSI and exports all the file names within the package to a spreadsheet. You could easily modify this to run as a batch process to pump out all the files from hundreds of MSI Packages. This information might be useful in determining common components etc, when developing MSI based setup routines.

This script prompts for an MSI (Windows Installer) Package, and an output location. It then queries the File table within MSI and exports all the file names within the package to a spreadsheet.

You could also modify the script to export ANY table from MSI (change the value of the variable 'Table' to the table you're interested in, and away you go!

N.B. This script is a modified version of a script from the MSI SDK, so credits etc to Microsoft......

 

' File Export v 1.0

' Export File Table from a given MSI Database to an Excel Spreadsheet
' J.Loomes Nov 2000



Option Explicit

Const msiOpenDatabaseModeReadOnly = 0


On Error Resume Next
Dim installer : Set installer = Nothing
Dim szMSI

szMSI = InputBox("Enter MSI File (including full path)", "Select MSI", "")
DIM folder : folder = InputBox("Enter Folder to Write Table to...", "Select Export Folder","")

Set installer = Wscript.CreateObject("WindowsInstaller.Installer") : CheckError

Dim database : Set database = installer.OpenDatabase(szMSI, msiOpenDatabaseModeReadOnly) : CheckError

Dim table, view, record

        table = "File"
   
        Set view = database.OpenView("SELECT 'Name' FROM _Tables")
        view.Execute : CheckError
        Do
            Set record = view.Fetch : CheckError
            If record Is Nothing Then Exit Do
            Export table, folder : CheckError
        Loop
        Set view = Nothing
       
   
        Export table, folder : CheckError


Wscript.Quit(0)

Sub Export(table, folder)
    Dim file :file = table & ".xls"
    database.Export table, folder, file
End Sub


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 & vbNewLine & errRec.FormatText
    End If
    Wscript.Echo message
    Wscript.Quit 2
End Sub

Page 1 of 1


Comment and Contribute

Your name/nickname

Your email

(Maximum characters: 1200). You have characters left.