DriveGet()

Auto Hotkey

DriveGet

Functions for retrieving various types of information about the computer's drive(s).

OutputVar := DriveGet(Cmd , Value)
Function Example: Drives := DriveGet("List","Fixed")

Returns a string of letters, one character for each drive letter in the system. For example: ACDEZ.

Drives := DriveGetList(Type)
Type

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

DriveGetCapacity

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

MB := DriveGetCapacity(Path)
Path

Any path contained by the drive.

DriveGetSpaceFree

Retrieves the free disk space of the drive which contains Path, in megabytes (rounded down to the nearest megabyte).

MB := DriveGetSpaceFree(Path)
Path

Any path contained by the drive.

DriveGetFilesystem

Retrieves the type of Drive's file system.

FS := DriveGetFilesystem(Drive)
Drive

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

The return value is one of the following words: FAT, FAT32, NTFS, CDFS (typically indicates a CD), UDF (typically indicates a DVD). If the drive does not contain formatted media, the return value is blank and ErrorLevel is set to 1.

DriveGetLabel

Retrieves Drive's volume label.

Label := DriveGetLabel(Drive)
Drive

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: DriveSetLabel("C:", "MyLabel").

DriveGetSerial

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

Serial := DriveGetSerial(Drive)
Drive

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

DriveGetType

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

Type := DriveGetType(Path)
Path

Any path contained by the drive.

DriveGetStatus

Retrieves Path's status.

Status := DriveGetStatus(Path)
Path

Any path contained by the drive.

The return value is one of the following strings:

StringNotes
UnknownMight indicate unformatted/RAW file system.
ReadyThis is the msot common.
NotReadyTypical for removable drives that don't contain media.
InvalidPath does not exist or is a network drive that is presently inaccessible, etc.

DriveGetStatusCD

Retrieves the media status of a CD or DVD drive.

Status := DriveGetStatusCD(Drive)
Drive

The drive letter followed by a colon. If omitted, the default CD/DVD drive will be used.

The return value is blank if the status cannot be determined. Otherwise, it is 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, the return value is 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, use DriveEject.

ErrorLevel

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 or Drive, such as \\MyServer\MyShare\

In general, Path (but not Drive) can be any path. Since NTFS supports mounted volumes and directory junctions, different paths with the same drive letter can produce different results (different amounts of free space, capacity, etc.).

Related

Drive

Example

; This is a working example script.
folder := DirSelect( , 3, "Pick a drive to analyze:")
if folder = ""
    return
list := DriveGetList()
cap := DriveGetCapacity(folder)
free := DriveGetSpaceFree(folder)
fs := DriveGetFilesystem(folder)
label := DriveGetLabel(folder)
serial := DriveGetSerial(folder)
type := DriveGetType(folder)
status := DriveGetStatus(folder)
MsgBox("
(Q
  All Drives: " list "
  Selected Drive: " folder "
  Drive Type: " type "
  Status: " status "
  Capacity: " cap " MB
  Free Space: " free " MB
  Filesystem: " fs "
  Volume Label: " label "
  Serial Number: " serial
))