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 ...
Get VBScript in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.