O'Reilly logo

VBScript in a Nutshell by Ron Petrusha, Paul Lomax, Matt Childs

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

Drive Object

Returned by

File.Drive property
FileSystemObject.Drives.Item property

Createable

No

Library

Microsoft Scripting Runtime

Description

Represents a single drive connected to the current machine, including a network drive. By using the Drive object, you can interrogate the system properties of any drive. In addition, you can use the Folder object returned by the Drive object’s RootFolder property as your foothold into the physical drive’s filesystem.

A new instance of the Drive object cannot be created. Instead, a Drive object that represents an existing physical drive typically is retrieved from the FileSystemObject object’s Drives collection, as in the following code fragment, which retrieves an object reference that represents the C: drive:

Dim oFS, oDrive
Set oFS = WScript.CreateObject("Scripting.FileSystemObject")
set oDrive = oFS.Drives("C")

For an overview of the File system object model, including the library reference needed to access it, see the “File System Object Model” entry.

Properties

All Drive object properties are read-only. In addition, removable media drives must be ready (i.e., have media inserted) for the Drive object to read certain properties.

AvailableSpace

Data Subtype: Long

Returns the number of bytes unused on the disk. Typically, the AvailableSpace property returns the same number as the Drive object’s FreeSpace property, although differences may occur on systems that support quotas. In addition, because the property is a variant Long, it is capable of storing ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required