home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 June / Chip_2001-06_cd1.bin / zkuste / vbasic / Data / Utility / MSISDK15.msi / WiGenXfm.vbs < prev    next >
Text File  |  2000-10-05  |  2KB  |  47 lines

  1. ' Windows Installer utility to generate a transform from two databases
  2. ' For use with Windows Scripting Host, CScript.exe or WScript.exe
  3. ' Copyright (c) 1999-2000, Microsoft Corporation
  4. ' Demonstrates use of Database.GenerateTransform and MsiDatabaseGenerateTransform
  5. '
  6. Option Explicit
  7.  
  8. Const msiOpenDatabaseModeReadOnly     = 0
  9. Const msiOpenDatabaseModeTransact     = 1
  10. Const msiOpenDatabaseModeCreate       = 3
  11.  
  12. If Wscript.Arguments.Count < 2 Then
  13.     Wscript.Echo "Windows Installer database tranform generation utility" &_
  14.         vbNewLine & " 1st argument is the path to the original installer database" &_
  15.         vbNewLine & " 2nd argument is the path to the updated installer database" &_
  16.         vbNewLine & " 3rd argument is the path to the transform file to generate" &_
  17.         vbNewLine & " If the 3rd argument is omitted, the databases are only compared" &_
  18.         vbNewLine &_
  19.         vbNewLine & "Copyright (C) Microsoft Corporation, 1999-2000.  All rights reserved."
  20.     Wscript.Quit 1
  21. End If
  22.  
  23. ' Connect to Windows Installer object
  24. On Error Resume Next
  25. Dim installer : Set installer = Nothing
  26. Set installer = Wscript.CreateObject("WindowsInstaller.Installer") : CheckError
  27.  
  28. ' Open databases and generate transform
  29. Dim database1 : Set database1 = installer.OpenDatabase(Wscript.Arguments(0), msiOpenDatabaseModeReadOnly) : CheckError
  30. Dim database2 : Set database2 = installer.OpenDatabase(Wscript.Arguments(1), msiOpenDatabaseModeReadOnly) : CheckError
  31. Dim transform:transform = ""  'Simply compare if no output transform file supplied
  32. If Wscript.Arguments.Count >= 3 Then transform = Wscript.Arguments(2)
  33. Dim different:different = Database2.GenerateTransform(Database1, transform) : CheckError
  34. If Not different Then Wscript.Echo "Databases are identical" Else If transform = Empty Then Wscript.Echo "Databases are different"
  35.  
  36. Sub CheckError
  37.     Dim message, errRec
  38.     If Err = 0 Then Exit Sub
  39.     message = Err.Source & " " & Hex(Err) & ": " & Err.Description
  40.     If Not installer Is Nothing Then
  41.         Set errRec = installer.LastErrorRecord
  42.         If Not errRec Is Nothing Then message = message & vbNewLine & errRec.FormatText
  43.     End If
  44.     Wscript.Echo message
  45.     Wscript.Quit 2
  46. End Sub
  47.