Function Reference


DriveGetDrive

Returns an array containing the enumerated drives.

DriveGetDrive ( "type" )

Parameters

type Type of drive to find:
    $DT_ALL ("ALL")
    $DT_CDROM ("CDROM")
    $DT_REMOVABLE ("REMOVABLE")
    $DT_FIXED ("FIXED")
    $DT_NETWORK ("NETWORK")
    $DT_RAMDISK ("RAMDISK")
    $DT_UNKNOWN ("UNKNOWN")

Constants are defined in AutoItConstants.au3

Return Value

Success: an array of strings (drive letter followed by colon) of drives found. The zeroth array element contains the number of drives.
Failure: sets the @error flag to 1.

Remarks

@error is set to 1 if the parameter is neither a $ constant nor a string equivalent, or if the computer has no drives of the requested type.
Example: On a computer that has no CD/DVD drive, DriveGetDrive("CDROM") sets @error to 1

Related

DriveGetFileSystem, DriveGetLabel, DriveGetSerial, DriveGetType, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, DriveStatus

Example

#include <AutoItConstants.au3>
#include <MsgBoxConstants.au3>

Local $aArray = DriveGetDrive($DT_ALL)
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]
                ; Show all the drives found and convert the drive letter to uppercase.
                MsgBox($MB_SYSTEMMODAL, "", "Drive " & $i & "/" & $aArray[0] & ":" & @CRLF & StringUpper($aArray[$i]))
        Next
EndIf