Functions for retrieving various types of information about the computer's drive(s).
Returns a string of letters, one character for each drive letter in the system. For example: ACDEZ.
Drives := DriveGetList(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.
Retrieves the total capacity of Path (e.g. C:\) in megabytes.
MB := DriveGetCapacity(Path)
Any path contained by the drive.
Retrieves the free disk space of the drive which contains Path, in megabytes (rounded down to the nearest megabyte).
MB := DriveGetSpaceFree(Path)
Any path contained by the drive.
Retrieves the type of Drive's file system.
FS := DriveGetFilesystem(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.
Retrieves Drive's volume label.
Label := DriveGetLabel(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")
.
Retrieves Drive's volume serial number expressed as a decimal integer.
Serial := DriveGetSerial(Drive)
The drive letter followed by a colon and an optional backslash, or a UNC name such \\server1\share1
.
Retrieves Path's drive type, which is one of the following words: Unknown, Removable, Fixed, Network, CDROM, RAMDisk.
Type := DriveGetType(Path)
Any path contained by the drive.
Retrieves Path's status.
Status := DriveGetStatus(Path)
Any path contained by the drive.
The return value is one of the following strings:
String | Notes |
---|---|
Unknown | Might indicate unformatted/RAW file system. |
Ready | This is the msot 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. |
Retrieves the media status of a CD or DVD drive.
Status := DriveGetStatusCD(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 function 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 function completes.
To eject or retract the tray, use DriveEject.
ErrorLevel is set to 1 if there was a problem or 0 otherwise.
Some of the functions 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.).
; 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 ))