MoonPoint Support Logo

 

Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
November
Sun Mon Tue Wed Thu Fri Sat
         
6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30
2024
Months
NovDec


Fri, Jan 27, 2006 2:34 pm

File Export

I wanted to view the files within an MSI file, i.e. a .msi file. I found a VBScript, called File Export at Export File List to Excel From MSI Using VBScript, which will create an Excel spreadsheet, i.e. a .xls file that lists the contents of an MSI file.


' 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

If saved as File-Export.vbs, the script can be run by double-clicking on it in Windows Explorer or typing File-Export.vbs, or cscript /nologo File-Export.vbs.

The script will prompt for the MSI file to process. Enter the full path to the file and the filename at the prompt. Make sure you type it correctly as you may see no error message and no output otherwise.

You will then be prompted for the export folder. A file named File.xls will be created in the directory you specify.

An examination of the MSI file contained within the whoami_setup.exe setup file for Microsoft's Windows 2000 Resource Kit utility Whoami, produced this File.xls, which can be viewed here.

If you would like further information on how an MSI file is structured, see Inside the MSI file format by Rob Mensching.

References:

  1. File Extension Details for .MSI
    FilExt - The File Extension Source
  2. Export File List to Excel From MSI Using VBScript
    By John Loomes
    December 7, 2000
  3. Whoami
    Microsoft Corporation
    March 8, 2001
  4. Inside the MSI file format
    Rob Mensching's blog
    November 25, 2003

[/os/windows/msi] permanent link

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo