DriveGet

Retrieves various types of information about the computer's drive(s).

DriveGet, OutputVar, SubCommand , Value

The OutputVar parameter is the name of the variable in which to store the result. The SubCommand and Value parameters are dependent upon each other and their usage is described below.

Sub-commands

For SubCommand, specify one of the following:

List

Retrieves a string of letters, one character for each drive letter in the system.

DriveGet, OutputVar, List , Type

Result example: ACDEZ. If Type is omitted, all drive types are retrieved. Otherwise, Type should be one of the following words to retrieve only a specific type of drive: CDROM, REMOVABLE, FIXED, NETWORK, RAMDISK, UNKNOWN.

Capacity (or Cap)

Retrieves the total capacity of a drive which contains the specified path, in megabytes.

DriveGet, OutputVar, Capacity, Path

Path is any path contained by the drive (might also work on UNC paths and mapped drives). The result is rounded down to the nearest whole number. Use DriveSpaceFree to determine the free space.

FileSystem (or FS)

Retrieves the type of the specified drive's file system.

DriveGet, OutputVar, FileSystem, Drive

Drive is the drive letter followed by a colon and an optional backslash, or a UNC name such \\server1\share1. The possible values for OutputVar are defined by the system; they include (but are not limited to) the following: NTFS, FAT32, FAT, CDFS (typically indicates a CD), or UDF (typically indicates a DVD). OutputVar will be made blank and ErrorLevel set to 1 if the drive does not contain formatted media.

Label

Retrieves the volume label of the specified drive.

DriveGet, OutputVar, Label, Drive

Drive is the drive letter followed by a colon and an optional backslash, or a UNC name such \\server1\share1.

To change the label, use the Drive's Label sub-command, such as Drive, Label, C:, MyLabel.

Serial

Retrieves the volume serial number of the specified drive.

DriveGet, OutputVar, Serial, Drive

Drive is the drive letter followed by a colon and an optional backslash, or a UNC name such \\server1\share1. See Format() or SetFormat for how to convert the result to hexadecimal.

Type

Retrieves the type of the drive which contains the specified path.

DriveGet, OutputVar, Type, Path

Path is any path contained by the drive (might also work on UNC paths and mapped drives). OutputVar is made blank if the path is invalid (for example, because the drive does not exist). Otherwise, it is set to one of the following words: Unknown, Removable, Fixed, Network, CDROM, RAMDisk.

Status

Retrieves the status of the drive which contains the specified path.

DriveGet, OutputVar, Status, Path

Path is any path contained by the drive (might also work on UNC paths and mapped drives). OutputVar is set to one of the following words:

Status Notes
Unknown Might indicate unformatted/RAW file system.
Ready This is the most common.
NotReady Typical for removable drives that don't contain media.
Invalid Path does not exist or is a network drive that is presently inaccessible, etc.

StatusCD

Retrieves the media status of a CD or DVD drive.

DriveGet, OutputVar, StatusCD , Drive

Drive is the drive letter followed by a colon. If Drive is omitted, the default CD/DVD drive will be used. OutputVar is made blank if the status cannot be determined. Otherwise, it is set to one of the following strings:

Status Meaning
not ready The drive is not ready to be accessed, perhaps due to being engaged in a write operation. Known limitation: "not ready" also occurs when the drive contains a DVD rather than a CD.
open The drive contains no disc, or the tray is ejected.
playing The drive is playing a disc.
paused The previously playing audio or video is now paused.
seeking The drive is seeking.
stopped The drive contains a CD but is not currently accessing it.

This sub-command will probably not work on a network drive or non-CD/DVD drive; if it fails in such cases or for any other reason, OutputVar is made blank and ErrorLevel is set to 1.

If the tray was recently closed, there may be a delay before the sub-command completes.

To eject or retract the tray, see the Drive's Eject sub-command.

Error Handling

[v1.1.04+]: This command is able to throw an exception on failure. For more information, see Runtime Errors.

ErrorLevel is set to 1 if there was a problem or 0 otherwise.

Remarks

Some of the sub-commands will accept a network share name as Path or Drive, such as \\MyServer\MyShare\.

Drive, DriveSpaceFree

Examples

Allows the user to select a drive in order to analyze it.

FileSelectFolder, folder,, 3, Pick a drive to analyze:
if not folder
    return
DriveGet, list, List
DriveGet, cap, Capacity, %folder%
DriveSpaceFree, free, %folder%
DriveGet, fs, FileSystem, %folder%
DriveGet, label, Label, %folder%
DriveGet, serial, Serial, %folder%
DriveGet, type, Type, %folder%
DriveGet, status, Status, %folder%
MsgBox All Drives: %list%`nSelected Drive: %folder%`nDrive Type: %type%`nStatus: %status%`nCapacity: %cap% M`nFree Space: %free% M`nFilesystem: %fs%`nVolume Label: %label%`nSerial Number: %serial%