Detecting External Hard Drives


SUBMITTED BY: Guest

DATE: May 30, 2013, 7:52 a.m.

FORMAT: Text only

SIZE: 1.6 kB

HITS: 1022

  1. #include <Array.au3>
  2. Local $drivelist = DriveGetDrive("FIXED"), $addspace = 0, $getspace, $systemdrives, $externaldrives
  3. ;~ _ArrayDisplay($drivelist)
  4. findexthdd()
  5. Func findexthdd()
  6. RunWait(@ComSpec & " /c " & 'wmic diskdrive get PNPDeviceID, size /format:csv | find /v "USBSTOR" > wmic.txt', @ScriptDir, @SW_HIDE)
  7. $file = FileOpen("wmic.txt")
  8. $readfile = FileRead($file)
  9. $readfile = StringSplit($readfile, ",")
  10. ;~ _ArrayDisplay($readfile)
  11. $last = $readfile[0]
  12. $totalsize = $readfile[$last]
  13. $totalsize = $totalsize / 1024 / 1024 / 1024 ;MB
  14. Do
  15. Local $c = 1
  16. $totalsize = StringTrimRight($totalsize, $c)
  17. $c = $c + 1
  18. $return = StringInStr($totalsize, ".")
  19. Until $return = 0
  20. $return = 1
  21. For $w = 1 To UBound($drivelist) - 1
  22. $getspace = DriveSpaceTotal($drivelist[$w]) / 1024
  23. Do
  24. Local $z = 1
  25. $getspace = StringTrimRight($getspace, $z)
  26. $z = $z + 1
  27. $return = StringInStr($getspace, ".")
  28. Until $return = 0
  29. $addspace += $getspace
  30. If $addspace <= $totalsize Then ;463 vs 465
  31. $systemdrives &= $drivelist[$w] & ","
  32. Else
  33. ;~ MsgBox(0, "", $drivelist[$w] & " is the f****** external hard drive!")
  34. $externaldrives &= $drivelist[$w] & ","
  35. EndIf
  36. Next
  37. $systemdrives = StringTrimRight($systemdrives, 1)
  38. $systemdrives = StringSplit($systemdrives, ",")
  39. _ArrayDisplay($systemdrives, "SYSTEM DRIVES LIST")
  40. $externaldrives = StringTrimRight($externaldrives, 1)
  41. $externaldrives = StringSplit($externaldrives, ",")
  42. _ArrayDisplay($externaldrives, "EXTERNAL DRIVES LIST")
  43. EndFunc ;==>findexthdd

comments powered by Disqus