win-pvdrivers

changeset 751:036172f7e1b2

Improved behaviour of waiting for all devices to install before allowing the msi installation to complete. Should work under Vista now.
author James Harper <james.harper@bendigoit.com.au>
date Sun Jan 10 10:13:47 2010 +1100 (2010-01-10)
parents cb83af6bcdef
children 2ecb5104c33a
files waitnopendinginstallevents/waitfordevices.vbs waitnopendinginstallevents/waitnopendinginstallevents.c
line diff
     1.1 --- a/waitnopendinginstallevents/waitfordevices.vbs	Sun Jan 10 10:11:16 2010 +1100
     1.2 +++ b/waitnopendinginstallevents/waitfordevices.vbs	Sun Jan 10 10:13:47 2010 +1100
     1.3 @@ -1,33 +1,45 @@
     1.4  Sub DoWaitForDevices()
     1.5    strComputer = "."
     1.6    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
     1.7 -  
     1.8 -  ' WScript.Echo "Waiting until at least one XEN\ device exists"
     1.9 -  
    1.10 +
    1.11    Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
    1.12      ("SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE " _
    1.13          & "Targetinstance ISA 'Win32_PnPEntity'")
    1.14    
    1.15    Set colItems = objWMIService.ExecQuery _
    1.16 -    ("Select * from Win32_PnPEntity WHERE DeviceID LIKE 'XEN\\%'")
    1.17 +    ("Select * from Win32_PnPEntity WHERE DeviceID LIKE 'XEN\\%' OR DeviceID LIKE 'PCI\\VEN_5853&DEV_0001%'")
    1.18    
    1.19    XenExistsFlag = False
    1.20 +
    1.21    For Each objItem in colItems
    1.22 -    ' WScript.Echo objItem.getObjectText_
    1.23 -    ' WScript.Echo "Devices Exist"
    1.24 -    XenExistsFlag = True
    1.25 -    Exit For
    1.26 +    If AreWeOkay(objItem) Then
    1.27 +      XenExistsFlag = True
    1.28 +      Exit For
    1.29 +    End If
    1.30    Next
    1.31  
    1.32    Do While Not XenExistsFlag
    1.33      Set objEventObject = colMonitoredEvents.NextEvent()
    1.34      Set objItem = objEventObject.Targetinstance
    1.35 -    ' WScript.Echo objItem.DeviceID
    1.36 -    If LCase(Left(objItem.DeviceID, 4)) = "xen\" Then
    1.37 -      ' WScript.Echo "New Xen Device Created"   
    1.38 +    If AreWeOkay(objItem) Then
    1.39        XenExistsFlag = True
    1.40      End If
    1.41    Loop
    1.42 +End Sub
    1.43  
    1.44 -  ' WScript.Echo "The End"
    1.45 -End Sub
    1.46 +
    1.47 +Function AreWeOkay(objItem)
    1.48 +  AreWeOkay = False
    1.49 +  If LCase(Left(objItem.DeviceID, 4)) = "xen\" Then
    1.50 +    ' At least one Xen\* item has been enumerated
    1.51 +    AreWeOkay = True
    1.52 +    Exit Function
    1.53 +  End If
    1.54 +  If LCase(Left(objItem.DeviceID, 21)) = "pci\ven_5853&dev_0001" Then
    1.55 +    If objItem.ConfigManagerErrorCode = 28 And LCase(objItem.Service) = "xenpci" Then
    1.56 +      ' Probably we need a reboot here... assume we're installed
    1.57 +      AreWeOkay = True
    1.58 +      Exit Function
    1.59 +    End If
    1.60 +  End If
    1.61 +End Function
     2.1 --- a/waitnopendinginstallevents/waitnopendinginstallevents.c	Sun Jan 10 10:11:16 2010 +1100
     2.2 +++ b/waitnopendinginstallevents/waitnopendinginstallevents.c	Sun Jan 10 10:13:47 2010 +1100
     2.3 @@ -18,11 +18,11 @@ main(ULONG argc, PCHAR argv[])
     2.4      timeout = atoi(argv[1]);
     2.5    }
     2.6  
     2.7 -  printf("timeout = %d\n", timeout);
     2.8 +  //printf("timeout = %d\n", timeout);
     2.9  
    2.10    ret = CMP_WaitNoPendingInstallEvents(timeout);
    2.11  
    2.12 -  printf("ret = %d\n", ret);
    2.13 +  //printf("ret = %d\n", ret);
    2.14  
    2.15    return ret;
    2.16  }