Identifying the File System Type

Microsoft® Windows® 2000 Scripting Guide

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 Note

  • The Win32_LogicalDisk class does not distinguish between the versions of NTFS found in Microsoft® Windows NT® 4.0 or Windows 2000. Instead, it reports both as "NTFS," even though the versions differ in capabilities. In these cases, you might want to identify the operating system version as well as the type of file system installed. For more information about identifying the operating system version, see "Computer Assets" in this book.

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