SHARE
Facebook X Pinterest WhatsApp

Export File List to Excel From MSI Using VBScript

Jul 20, 2010
ServerWatch content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More




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

Recommended for you...

What Is a Container? Understanding Containerization
What Is a Print Server? | How It Works and What It Does
Nisar Ahmad
Dec 8, 2023
What Is a Network Policy Server (NPS)? | Essential Guide
Virtual Servers vs. Physical Servers: Comparison and Use Cases
Ray Fernandez
Nov 14, 2023
ServerWatch Logo

ServerWatch is a top resource on servers. Explore the latest news, reviews and guides for server administrators now.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.