Returning a Collection of Disk Drives

Microsoft® Windows® 2000 Scripting Guide

Before you can manage disk drives on a computer, you need to know which disk drives are actually available on that computer. The FileSystemObject allows you to return a collection of all the drives installed on a computer, including removable drives and mapped network drives (in other words, any drive with a drive letter).

To return this collection, create an instance of the FileSystemObject, and then create a reference to the Drives property. After the collection has been returned, you can use a For Each loop to iterate through the collection.

For example, the script in Listing 4.1 returns a collection of all the drives installed on a computer and then echoes the drive letter for each drive in the collection.