<P><A href="http://hi.baidu.com/iokey/blog/item/11def344fb1e1087b2b7dc57.html" target=_blank>http://hi.baidu.com/iokey/blog/item/11def344fb1e1087b2b7dc57.html</A></P>
<P> </P>
<P> </P>
<P>$strComputer = "."<BR>$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\cimv2")</P>
<P>$colEvents = $objWMIService.ExecNotificationQuery _<BR>("Select * From __InstanceOperationEvent Within 5 Where " _<BR>& "TargetInstance isa 'Win32_LogicalDisk'")</P>
<P>While 1<BR>$objEvent = $colEvents.NextEvent<BR>If $objEvent.TargetInstance.DriveType = 2 Then <BR>Select <BR>Case $objEvent.Path_.Class()="__InstanceCreationEvent"<BR>Consolewrite("Drive " & $objEvent.TargetInstance.DeviceId & "has been added." & @CR)<BR>Case $objEvent.Path_.Class()="__InstanceDeletionEvent"<BR>Consolewrite("Drive " & $objEvent.TargetInstance.DeviceId & "has been removed."& @CR)<BR>EndSelect<BR>EndIf<BR>WEnd</P>
<P> </P>