Managing Disk Drives

Microsoft® Windows® 2000 Scripting Guide

Disk drive management is an important part of system administration. As a system administrator, it is important for you to know the disk drives that are installed on a computer; it is equally important for you to know the characteristics of those disk drives, including such things as the drive type (floppy disk, hard disk, CD-ROM), drive size, and the amount of free disk space available on each drive.

As a script writer, you have two primary options for managing disk drives: the FileSystemObject and Windows Management Instrumentation (WMI). In general, WMI is the preferred technology for scripts that manage disk drives, for several reasons:

  • WMI can return a number of properties that cannot be obtained by using the FileSystemObject, including physical characteristics such as heads, sectors, and cylinders.

  • WMI can return a targeted set of drives (for example, only hard drives).

    The FileSystemObject cannot return a targeted set of drives. Instead, the FileSystemObject requires the script to return a collection of all the drives and then iterate through the collection to pick out the drives of interest. (You can, however, use the FileSystemObject to return an individual drive simply by specifying the appropriate drive letter.)

  • WMI can be used to return drive information from remote computers.

    The FileSystemObject cannot be run on remote computers unless it is used in conjunction with the WshController object.

Although WMI might be the preferred technology for returning disk drive information, there are at least two good reasons to be familiar with the FileSystemObject. First, you might have older computers running an operating system that does not have WMI installed. (For example, Microsoft® Windows® 98 did not ship with WMI, although it is possible to download and install WMI on this operating system.)

Second, and perhaps most important, script writers have typically used the FileSystemObject whenever they wrote a script requiring disk drive information. Because of that, you are likely to encounter the FileSystemObject when reading scripts written by other script writers.