Guest User

Untitled

a guest
Apr 7th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.44 KB | None | 0 0
  1. #Region ;**** Directives created by AutoIt3Wrapper_GUI ****
  2. #AutoIt3Wrapper_Change2CUI=y
  3. #EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
  4. #include <Array.au3>
  5.  
  6. dim $USB_DeviceID
  7. dim $USB_DriveLetter
  8. dim $USB_Partition
  9.  
  10.  
  11. $WMIObj = ObjGet("winmgmts:\\" & @ComputerName & "\root\cimv2")
  12.     If @error Then
  13.         MsgBox(0, "Error", "Error getting wmi : " & Hex(@error, 8))
  14.     Else
  15.         $DiskObjItems = $WMIObj.ExecQuery("select * from win32_diskdrive where InterfaceType='USB'")
  16.         If IsObj($DiskObjItems) Then
  17.             For $oItem In $DiskObjItems
  18.                 ConsoleWrite($oItem.Index & ": " & $oItem.Caption & " - " & $oItem.InterfaceType & " - " & $oItem.DeviceID & @CRLF)
  19.                 $USB_DeviceID = $oItem.DeviceID
  20.             Next
  21.         EndIf
  22.         $PartitionsObjects = $WMIObj.ExecQuery("associators of {Win32_DiskDrive.DeviceID='" & $USB_DeviceID & "'} where AssocClass = Win32_DiskDriveToDiskPartition")
  23.         If IsObj($PartitionsObjects) Then
  24.             For $oItem In $PartitionsObjects
  25. ;~              MsgBox(0, "test", "test")
  26.                 $USB_Partition = $oItem.DeviceID
  27.                 ConsoleWrite($oItem.DeviceID & @CRLF)
  28.             Next
  29.         EndIf
  30.         $VolumesObjects = $WMIObj.ExecQuery("associators of {Win32_DiskPartition.DeviceID='" & $USB_Partition & "'} where AssocClass = Win32_LogicalDiskToPartition")
  31.         If IsObj($VolumesObjects) Then
  32.             For $oItem In $VolumesObjects
  33. ;~              MsgBox(0, "test", "test")
  34.                 $USB_DriveLetter = $oItem.DeviceID
  35.                 ConsoleWrite($oItem.DeviceID & @CRLF)
  36.             Next
  37.         EndIf
  38.  
  39.     EndIf
Add Comment
Please, Sign In to add comment