win-pvdrivers

view waitnopendinginstallevents/waitfordevices.vbs @ 1001:c21dd04d3ae6

Less noise for xennet6
author James Harper <james.harper@bendigoit.com.au>
date Fri Dec 14 21:26:22 2012 +1100 (2012-12-14)
parents 036172f7e1b2
children
line source
1 Sub DoWaitForDevices()
2 strComputer = "."
3 Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
5 Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
6 ("SELECT * FROM __InstanceOperationEvent WITHIN 5 WHERE " _
7 & "Targetinstance ISA 'Win32_PnPEntity'")
9 Set colItems = objWMIService.ExecQuery _
10 ("Select * from Win32_PnPEntity WHERE DeviceID LIKE 'XEN\\%' OR DeviceID LIKE 'PCI\\VEN_5853&DEV_0001%'")
12 XenExistsFlag = False
14 For Each objItem in colItems
15 If AreWeOkay(objItem) Then
16 XenExistsFlag = True
17 Exit For
18 End If
19 Next
21 Do While Not XenExistsFlag
22 Set objEventObject = colMonitoredEvents.NextEvent()
23 Set objItem = objEventObject.Targetinstance
24 If AreWeOkay(objItem) Then
25 XenExistsFlag = True
26 End If
27 Loop
28 End Sub
31 Function AreWeOkay(objItem)
32 AreWeOkay = False
33 If LCase(Left(objItem.DeviceID, 4)) = "xen\" Then
34 ' At least one Xen\* item has been enumerated
35 AreWeOkay = True
36 Exit Function
37 End If
38 If LCase(Left(objItem.DeviceID, 21)) = "pci\ven_5853&dev_0001" Then
39 If objItem.ConfigManagerErrorCode = 28 And LCase(objItem.Service) = "xenpci" Then
40 ' Probably we need a reboot here... assume we're installed
41 AreWeOkay = True
42 Exit Function
43 End If
44 End If
45 End Function