Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Enterprise scripting often involves configuring hardware and software on remote computers; in turn, this requires you to know, in advance, the type of disk drives installed on a computer. For example, a script that installs an application on drive E works only if drive E is a hard disk. If drive E happens to represent a floppy disk or a CD-ROM drive, the script fails.
Fortunately, you can use the Win32_LogicalDisk class to verify the drive type for each disk drive installed on a computer.
Listing 10.4 contains a script that identifies the drives and drive types installed on a computer. To carry out this task, the script must perform the following steps:
This query returns a collection consisting of all the logical disk drives (including hard disks, floppy disks, and compact discs) installed on the computer.
The Win32_LogicalDisk class returns the value of the DriveType property as an integer. Therefore, a series of Select Case statements is used to convert the value to a text string. For example, if the DriveType is equal to 3, the string "Local hard disk" is echoed to the screen.
Listing 10.4 Identifying Drives and Drive Types
|
|
Send us your feedback | « Previous | Next » |