DriveGet

AutoHotkey GUI

DriveGet

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

DriveGet, OutputVar, Cmd , Value

Parameters

OutputVar

The name of the variable in which to store the result of Cmd.

Cmd, Value
See list below.

Cmd, Value

The Cmd and Value parameters are dependent upon each other and their usage is described below. If a problem is encountered OutputVar is made blank and ErrorLevel is set to 1.

List [, Type]: Sets OutputVar to be a string of letters, one character for each drive letter in the system. For 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), Path: Retrieves the total capacity of Path (e.g. C:\) in megabytes. Use DriveSpaceFree to determine the free space.

Filesystem (or FS), Drive: Retrieves the type of Drive's file system, where Drive is the drive letter followed by a colon and an optional backslash, or a UNC name such \\server1\share1. OutputVar will be set to one of the following words: FAT, FAT32, NTFS, CDFS (typically indicates a CD), UDF (typically indicates a DVD). OutputVar will be made blank and ErrorLevel set to 1 if the drive does not contain formatted media.

Label, Drive: Retrieves Drive's volume label, where Drive is the drive letter followed by a colon and an optional backslash, or a UNC name such \\server1\share1. To change the label, follow this example: Drive, Label, C:, MyLabel.

Serial, Drive: Retrieves Drive's volume serial number expressed as decimal integer, where Drive is the drive letter followed by a colon and an optional backslash, or a UNC name such \\server1\share1. See SetFormat for how to convert it to hexadecimal.

Type, Path: Retrieves Path's drive type, which is one of the following words: Unknown, Removable, Fixed, Network, CDROM, RAMDisk.

Status, Path: Retrieves Path's status, which is one of the following words: Unknown (might indicate unformatted/RAW), Ready, 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 [, Drive]: Retrieves the media status of a CD or DVD drive, where 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:

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 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 command completes.

To eject or retract the tray, see the Drive command.

ErrorLevel

[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 commands will accept a network share name as Path, such as \\MyServer\MyShare\

Related

Drive, DriveSpaceFree

Example

; This is a working example script.
FileSelectFolder, folder, , 3, Pick a drive to analyze:
if folder =
    return
DriveGet, list, list
DriveGet, cap, capacity, %folder%
DriveSpaceFree, free, %folder%
DriveGet, fs, fs, %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%