"Drive" Objects Representing Disk Drives
This section describes Drive object properties. A tutorial example is provided on how to list all drives and their properties on the local machine.
"Drive": An object representing a drive of the file system.
It offers the following methods and properties:
- "DriveLetter": Property to return the drive letter.
- "DriveType": Property to return the drive type, 0 for unknown, 1 for removable,
2 for fixed, 3 for network, 4 for CD-ROM, and 5 for RAM disk.
- "FileSystem": Property to return the file organization type of the drive.
- "IsReady": Property to return the status of the drive.
- "Path": Property to return the path name of the drive.
- "SerialNumber": Property to return the serial number of the drive.
- "ShareName": Property to return the share name of the drive.
- "VolumeName" Property to return the volume name of the drive.
- "TotalSize": Property to return the total space in units of byte.
- "AvailableSpace": Property to return the free space on the drive in units of byte.
- "FreeSpace": Property to return the free space on the drive in units of byte.
What's the difference between FreeSpace and AvailableSpace?
- "RootFolder": Property to return a "Folder" object representing the root directory
of the drive.
Here is a VBScript example showing you how to use Drive object properties:
- Copyright (c) 2015, HerongYang.com, All Rights Reserved.
' Creating a FileSystemObject object
set fs = CreateObject("Scripting.FileSystemObject")
' Display all drives and their properties
set ds = fs.Drives
document.writeln("List of drives:")
for each d in ds
document.writeln("Drive Letter = " & d.DriveLetter)
document.writeln("Drive Type = " & d.DriveType)
document.writeln("Is Ready = " & d.IsReady)
document.writeln("Path = " & d.Path)
document.writeln("Share Name = " & d.ShareName)
if d.IsReady then
document.writeln("File System = " & d.FileSystem)
document.writeln("Serial Number = " & d.SerialNumber)
document.writeln("Volume Name = " & d.VolumeName)
document.writeln("Total Size = " & d.TotalSize)
document.writeln("Free Space = " & d.FreeSpace)
When you load this example into IE, you will get a security warning.
You can ignore it and get the output:
List of drives:
Drive Letter = C
Drive Type = 2
Is Ready = True
Path = C:
Share Name =
File System = NTFS
Serial Number = 1545214583
Volume Name = New Volume
Total Size = 9697603584
Free Space = 4838227968
Drive Letter = D
Drive Type = 4
Is Ready = False
Path = D:
Share Name =
Note that: Drive "D:" is my CD-ROM, which is not ready, because it is not loaded with any CD.
Table of Contents
About This Book
Introduction of VBScript - Visual Basic Scripting Edition
Variant Data Type, Subtypes, and Literals
Numeric Comparison Operations and Logical Operations
String Operations - Concatenation and Comparison
Variable Declaration and Assignment Statement
Expression and Order of Operation Precedence
Statement Syntax and Statement Types
Array Data Type and Related Statements
Array References and Array Assignment Statements
Conditional Statements - "If ... Then" and "Select Case"
Loop Statements - "For", "While", and "Do"
"Function" and "Sub" Procedures
Inspecting Variables Received in Procedures
Error Handling Flag and the "Err" Object
Regular Expression Pattern Match and Replacement
►scrrun.dll - Scripting Runtime DLL Library
Scripting Runtime DLL Library Overview
"Dictionary" Objects to Store Keys and Values
"FileSystemObject" Objects to Manage File Systems
►"Drive" Objects Representing Disk Drives
"Folder" Objects Representing File Folders
"File" Objects Representing Files
"TextStream" Objects Representing File Input and Output
Creating Your Own Classes
IE Web Browser Supporting VBScript
IIS ASP Server Supporting VBScript
WSH (Windows Script Host)
PDF Printing Version