home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / sysmgmt / msi / sequence / sequence.bas
BASIC Source File  |  1997-08-07  |  2KB  |  45 lines

  1. ' Sample script for sequencing an installation from outside MSI - test code only, hardwired paths
  2. ' Requires AutoApi.DLL to be self-registered (use REGSVR32 AutoApi.DLL)
  3. Sub SingleStep()
  4.    Dim Engine As Object, ActionView As Object
  5.    Dim Sequence As Integer, Action As String, Condition As String
  6.    Dim Test As Integer, Result As Integer
  7.    Dim ExitAction As String, ErrorAction As String, CancelAction As String
  8.    Set MsiAuto = CreateObject("Msi.ApiAutomation")
  9.    MsiAuto.UILevel = 5 'Full UI (no enums yet)
  10.    MsiAuto.EnableLog "warped", "C:\temp\step.log"
  11.    Set Engine = MsiAuto.OpenPackage("C:\msi\testdb\testdb.msi")
  12. '  Engine.Property("SOURCEDIR") = "C:\msi\testdb"  ' needed if source location different than database
  13.    Set Database = Engine.Database
  14.    Set ActionView = Database.OpenView("SELECT Action,Condition,Sequence FROM InstallSequence ORDER BY Sequence")
  15.    ActionView.Execute
  16.    Do
  17.       Set Record = ActionView.Fetch
  18.       If Record Is Nothing Then Exit Do
  19.       Sequence = Record.IntegerData(3)
  20.       Action = Record.StringData(1)
  21.       Condition = Record.StringData(2)
  22.       If Sequence <= 0 Then
  23.          Debug.Print Sequence; " Action = "; Action; "  (exit dialog)"
  24.          If (Sequence = -1) Then ExitAction = Action
  25.          If (Sequence = -2) Then CancelActon = Action
  26.          If (Sequence = -3) Then ErrorAction = Action
  27.       Else
  28.          Test = Engine.EvaluateCondition(Condition)
  29.          Debug.Print Sequence; " Action = "; Action; "  Condition:"; Test;
  30.          If Test = iecError Then Debug.Print "Invalid Expression"; Condition
  31.          If Test <> iecFalse Then
  32.             Result = Engine.DoAction(Action)
  33.             Debug.Print "  Result: "; Result
  34.             If Result <> iesSuccess And Result <> iesNoAction Then Exit Do
  35.          Else
  36.             Debug.Print "(not called)"
  37.          End If
  38.       End If
  39.    Loop
  40.    If Result = iesSuccess Then Engine.DoAction (ExitAction)
  41.    If Result = iesFailure Then Engine.DoAction (ErrorAction)
  42.    If Result = iesUserExit Then Engine.DoAction (CancelAction)
  43.    Debug.Print "Sequence completed"
  44. End Sub
  45.