Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003

Microsoft® Windows® 2000 Scripting Guide

« Previous | Next »   

The type of file system installed on a volume determines the things you can and cannot do with that volume. For example, if you have a dual-boot computer and need to access a volume from Microsoft® Windows® Millennium Edition, you must format that volume using either FAT or FAT32; Windows Millennium Edition cannot access NTFS volumes. By contrast, if you need to enable disk quotas or use file and folder permissions, you must do this on an NTFS volume; neither capability is supported by FAT or FAT32.

The Win32_LogicalDisk class can be used to identify the file system installed on any logical drive on a computer.

Note

Scripting Steps

Listing 10.16 contains a script that identifies the file system used on each logical disk on a computer. To carry out this task, the script must perform the following steps:

  1. Create a variable to specify the computer name.
  2. Use a GetObject call to connect to the WMI namespace root\cimv2, and set the impersonation level to "impersonate."
  3. Use the ExecQuery method to query the Win32_LogicalDisk class.

    This returns a collection of all the logical disk drives installed on the computer.

  4. For each logical disk drive in the collection, echo the device ID and the type of file system installed on the drive.

Listing 10.16   Identifying the File System Type

1 2 3 4 5 6 7 8 9

strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") Set colDisks = objWMIService.ExecQuery _ ("SELECT * FROM Win32_LogicalDisk") For Each objDisk in colDisks Wscript.Echo "Device ID: " & objDisk.DeviceID    Wscript.Echo "File System: " & objDisk.FileSystem Next


 Send us your feedback « Previous | Next »   

Категории