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. For example: ACDEZ.

DriveGet, OutputVar, List , Type

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

Retrieves the total capacity of Path (e.g. C:\) in megabytes.

DriveGet, OutputVar, Capacity, Path

Use DriveSpaceFree to determine the free space. The word Cap can be used in place of Capacity.

FileSystem

Retrieves the type of 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. 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. The word FS can be used in place of FileSystem.

Label

Retrieves Drive's volume label.

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, follow this example: Drive, Label, C:, MyLabel.

Serial

Retrieves Drive's volume serial number expressed as decimal integer.

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 SetFormat for how to convert it to hexadecimal.

Type

Retrieves Path's drive type.

DriveGet, OutputVar, Type, Path

OutputVar is set to one of the following words: Unknown, Removable, Fixed, Network, CDROM, RAMDisk.

Status

Retrieves Path's status.

DriveGet, OutputVar, Status, Path

OutputVar is set to 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

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:

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 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\.

Related

Drive, DriveSpaceFree

Examples

Example #1

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%