FREE Subscription to Dr. Dobb’s Digest: Same Great Content, New Digital Edition
Site Archive (Complete)
Dobbs M-Dev
Email
Print
Reprint

add to:
Del.icio.us
Digg
Google
Furl
Slashdot
Y! MyWeb
Blink
March 01, 2001

Customizing Windows Installer

(Page 12 of 24)
March 2001/Customizing Windows Installer/Listing 1

Listing 1: 1stfile.vbs — Inspecting file versions

Option Explicit
Public installer, database

Const msiOpenDatabaseModeReadOnly     = 0


' Connect to Windows Installer object
REM On Error Resume Next
Set installer = Nothing
Set installer = Wscript.CreateObject("WindowsInstaller.Installer")_
    : CheckError

' Open database
Dim databasePath:databasePath = "orca.msi"
Set database = installer.OpenDatabase(databasePath, _
    msiOpenDatabaseModeReadOnly) : CheckError

ListFiles

Wscript.Quit 0

' List all files in database
Sub ListFiles
Dim view, record, afile, aversion, fullmsg
    fullmsg = ""
    Set view = database.OpenView(_
        "SELECT `FileName`,`Version` FROM `File`") : CheckError
    view.Execute : CheckError
    Do
        Set record = view.Fetch : CheckError
        If record Is Nothing Then Exit Do
        afile = record.StringData(1)
        aversion = record.stringdata (2) 
        fullmsg = fullmsg & afile & " " & aversion & vbcrlf
    Loop
    msgbox fullmsg
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 & _
            vbLf & errRec.FormatText
    End If
    Fail message
End Sub

Sub Fail(message)
    Wscript.Echo message
    Wscript.Quit 2
End Sub
Previous Page | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 Next Page
TOP 5 ARTICLES
No Top Articles.



MICROSITES
FEATURED TOPIC

ADDITIONAL TOPICS

INFO-LINK