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:
<html>
<body>
<!-- drive_test.html
- Copyright (c) 2015, HerongYang.com, All Rights Reserved.
-->
<pre>
<script language="vbscript">
' 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)
end if
next
</script>
</pre>
</body>
</html>
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.