Function Reference


DriveGetType

Returns drive type.

DriveGetType ( "path" [, operation = 1] )

Parameters

path Path of drive to receive information from.
operation [optional] The drive type operation to perform.
    $DT_DRIVETYPE (1) = the type of drive (default)
    $DT_SSDSTATUS (2) = SSD status of the drive
    $DT_BUSTYPE (3) = the bus type of drive

Constants are defined in AutoItConstants.au3.

Return Value

Success: See remarks.
Failure: Sets the @error flag to 1 if a bad path was given, or if the operation failed. Return value is "".

Remarks

If the mode parameter is $DT_DRIVETYPE (1), returns the type of drive. The path must be a string volume name, such as "C:\". Return values are:
"Unknown", "Removable", "Fixed", "Network", "CDROM", "RAMDisk"

If the mode parameter is $DT_SSDSTATUS (2), returns the SSD status of the drive. The path can be a string volume name, or an integer drive index. Return values are:
"SSD", "" (blank)

If the mode parameter is $DT_BUSTYPE (3), returns the bus type of the drive. The path can be a string volume name, or an integer drive index. Return values are:
"Unknown", "SCSI", "ATAPI", "ATA", "1394", "SSA", "Fibre", "USB", "RAID", "iSCSI", "SAS", "SATA", "SD", "MMC", "Virtual", "FileBackedVirtual"

Related

CDTray, DriveGetDrive, DriveGetFileSystem, DriveGetLabel, DriveGetSerial, DriveSetLabel, DriveSpaceFree, DriveSpaceTotal, DriveStatus

Example

Example 1

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

; Check the drive type for C:\
Local $sInfo = DriveGetType("C:\")
MsgBox($MB_SYSTEMMODAL, "", "Drive Type: " & $sInfo)

; Check the SSD status for C:\
$sInfo = DriveGetType("C:\", $DT_SSDSTATUS)
MsgBox($MB_SYSTEMMODAL, "", "Drive SSD: " & $sInfo)

; Check the SSD status for disk 0
$sInfo = DriveGetType(0, $DT_SSDSTATUS)
MsgBox($MB_SYSTEMMODAL, "", "Drive SSD: " & $sInfo)

; Check the bus type status for disk 0
$sInfo = DriveGetType(0, $DT_BUSTYPE)
MsgBox($MB_SYSTEMMODAL, "", "Drive Bus: " & $sInfo)

Example 2, with disk number, partition number

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

Local $aDrive = DriveGetDrive("ALL")
Local $sOutput = "Nb Drives = " & $aDrive[0] & @CRLF & @CRLF, $sType, $sSsdStatus, $sBusType, $nDrive = 0

For $i = 1 To $aDrive[0]
    $sBusType = DriveGetType($aDrive[$i], $DT_BUSTYPE)
    $sSsdStatus = DriveGetType($aDrive[$i], $DT_SSDSTATUS)
    $sType = DriveGetType($aDrive[$i] & "\")
    $sOutput &= "Drive " & $aDrive[$i] & @TAB & "Disk #" & _WinAPI_GetDriveNumber($aDrive[$i])[1] & @TAB & _
            "Partition #" & _WinAPI_GetDriveNumber($aDrive[$i])[2] & @TAB & "SSD Status = " & $sSsdStatus & @TAB & "BusType = " & $sBusType & @CRLF
Next

MsgBox($MB_SYSTEMMODAL, "DriveGetType (v" & @AutoItVersion & ")", $sOutput)