Binding to a Specific Disk Drive
Microsoft® Windows® 2000 Scripting Guide
If you know in advance which drive you want to bind to (for example, drive C, or the shared folder \\accounting\receivables), you can use the GetDrive method to bind directly to the drive. This allows you to retrieve information for a specific drive, without having to return and iterate through an entire collection.
The GetDrive method requires a single parameter: the driver letter of the drive or the UNC path to the shared folder. To specify a drive letter, you can use any of the following formats:
C
C:
C:\
The script shown in Listing 4.2 creates an instance of the FileSystemObject, uses the GetDrive method to bind directly to drive C, and then echoes the amount of available space on the drive.
Listing 4.2 Binding to a Single Drive
1 2 3 |
|
Notice that no For Each loop is required to retrieve the drive properties. This is because the script returns an individual drive object rather than a collection of drive objects. Therefore, there is no collection to iterate through.