DigDeep Posted April 26, 2018 Share Posted April 26, 2018 Hi, I am in need of some urgent help please. I am trying to detect how many Partitions are available on the FIXED Internal Drive. Unfortunately, if I am connecting an external Hard Drive via USB, it will be still showing as FIXED Drive. Can someone please help in getting this fixed ASAP. Note: My purpose is to only detect the number of partitions made on the Internal Hard Drives and exclude anything detected as USB Drive. I see many forums have discussed some or the other sort of this already but I am not able to get any of them Thanks. #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> Local $aArray = DriveGetDrive($DT_FIXED) If @error Then ; An error occurred when retrieving the drives. MsgBox($MB_SYSTEMMODAL, "", "It appears an error occurred.") Else For $i = 1 To $aArray[0] If $i & "/" & $aArray[0] > 1 / 1 Then Local $dt = DriveGetType($aArray[$i]) If $dt = $DT_BUSTYPE And $aArray[$i] <> "C:" Then MsgBox($MB_SYSTEMMODAL, "", "Additional Drive (" & $dt & "): " & $i & "/" & $aArray[0] & ":" & @CRLF & StringUpper($aArray[$i])) ; Display if Drive letter is USB Else MsgBox($MB_SYSTEMMODAL, "", "Drive (" & $dt & ") = " & $aArray[$i]) EndIf EndIf Next EndIf Link to comment Share on other sites More sharing options...
mikell Posted April 26, 2018 Share Posted April 26, 2018 You might first use : If DriveGetType($disk, $DT_BUSTYPE) <> "USB" Then... and then check the partitions using WMI Link to comment Share on other sites More sharing options...
DigDeep Posted April 26, 2018 Author Share Posted April 26, 2018 Thanks @mikell I did it this way and got it fixed. #include <AutoItConstants.au3> #include <MsgBoxConstants.au3> Local $aArray = DriveGetDrive($DT_FIXED) If @error Then ; An error occurred when retrieving the drives. MsgBox($MB_SYSTEMMODAL, "", "It appears an error occurred.") Else For $i = 1 To $aArray[0] If $i & "/" & $aArray[0] > 1 / 1 Then Local $dt = DriveGetType($aArray[$i], $DT_BUSTYPE) If $dt = "USB" Then MsgBox($MB_SYSTEMMODAL, "", "USB Drive (" & $dt & "): " & $i & "/" & $aArray[0] & ":" & @CRLF & StringUpper($aArray[$i])) ; Display if Drive letter is USB Else MsgBox($MB_SYSTEMMODAL, "", "Internal Drive (" & $dt & ") = " & $aArray[$i]) EndIf EndIf Next EndIf Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now