title: Finding USB drive letter with VBScript
body: <p>I found this script on <a href="http://network-blog.lan-secure.com/2008/03/usb-detection-using-wmi-script.html" rel="nofollow">http://network-blog.lan-secure.com/2008/03/usb-detection-using-wmi-script.html</a></p>
  
  <pre><code> strComputer = "." '(Any computer name or address)
   Set wmi = GetObject("winmgmts:\\" &amp; strComputer &amp; "\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
  </code></pre>
  
  <p>This script is next to what I need. It detects the insertion of a usb drive. How to modify it to find the drive letter of the usb drive? If I get the drive letter, then on insertion instead of echoing "USB device found" I will be able to run command line scanner of Avast Antivirus to automatically scan the drive on Insertion. Please guide!</p>