Microsoft® Windows® 2000 Scripting Guide
« Previous | Next »
Using drive letters as the sole means of identifying a logical drive can cause confusion. Drive letters can vary not only from computer to computer (depending on how many drives are installed on each computer), but can also vary over time on an individual computer. For example, a computer might have a removable drive connected, and thus have drives A, B, C, D, and E. Later, the drive might be disconnected and the computer would then have drives A, B, C, and D.
One way to work around this problem is to use volume names (also referred to as volume labels) to help differentiate logical drives. For example, a computer might have the following logical drives:
Instead of referring to these as drives C, D, and E, you can give them the volume names System, Applications, and Data. This makes it easier to identify the individual drives, particularly if other computers in the organization are configured in a different manner, for example, with drive D hosting data and drive E hosting applications. Using a consistent naming scheme across the organization helps facilitate administration and makes it easier for users who might use a different computer each time they log on.
You can use the Win32_LogicalDisk class to rename volumes on a computer. When renaming volumes, consider the following issues:
Listing 10.5 contains a script that changes the name of a volume. To carry out this task, the script must perform the following steps:
To ensure that only drive C receives the name change, a Where clause is included to limit data retrieval to those drives with a DeviceID of C. The query thus returns a collection consisting of only those logical disk drives with a DeviceID of C.
Listing 10.5 Changing Volume Names
|
|
Send us your feedback | « Previous | Next » |