我在http://network-blog.lan-secure.com/2008/03/usb-detection-using-wmi-script.html上找到了这个脚本
strComputer = "." '(Any computer name or address)
Set wmi = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set wmiEvent = wmi.ExecNotificationQuery("select * from __InstanceOperationEvent within 1 where TargetInstance ISA 'Win32_PnPEntity' and TargetInstance.Description='USB Mass Storage Device'")
While True
Set usb = wmiEvent.NextEvent()
Select Case usb.Path_.Class
Case "__InstanceCreationEvent" WScript.Echo("USB device found")
Case "__InstanceDeletionEvent" WScript.Echo("USB device removed")
Case "__InstanceModificationEvent" WScript.Echo("USB device modified")
End Select
Wend
这个脚本在我需要的旁边。它检测 USB 驱动器的插入。如何修改它以找到USB驱动器的驱动器号?如果我得到驱动器号,那么在插入时而不是回显“找到 USB 设备”,我将能够运行 Avast Antivirus 的命令行扫描程序以在插入时自动扫描驱动器。请指导!