标题: [转贴] VBS检测可移动磁盘的连接与断开 [打印本页]
作者: tmplinshi 时间: 2011-7-31 17:18 标题: VBS检测可移动磁盘的连接与断开
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
-
- Set colEvents = objWMIService.ExecNotificationQuery _
- ("Select * From __InstanceOperationEvent Within 10 Where " _
- & "TargetInstance isa 'Win32_LogicalDisk'")
-
- Do While True
- Set objEvent = colEvents.NextEvent
- If objEvent.TargetInstance.DriveType = 2 Then
- Select Case objEvent.Path_.Class
- Case "__InstanceCreationEvent"
- Wscript.Echo "Drive " & objEvent.TargetInstance.DeviceId & _
- " has been added."
- Case "__InstanceDeletionEvent"
- Wscript.Echo "Drive " & objEvent.TargetInstance.DeviceId & _
- " has been removed."
- End Select
- End If
- Loop
复制代码
转自: http://blogs.technet.com/b/heysc ... gets-connected.aspx
作者: BillGates 时间: 2011-7-31 20:10
不错,支持一下。
作者: Hello123World 时间: 2011-8-1 16:51
犀利啦,这都看的懂。——这英语得多少级啊!
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |