Enumerating NTFS Properties
Microsoft® Windows® 2000 Scripting Guide
NTFS properties play an important role in determining the optimal configuration of your file system. Despite that, few system administrators are aware of how these properties have been configured, largely because no graphical user tool for viewing NTFS properties is provided with the operating system. In fact, you can only view and configure these properties through the registry. You can find the registry entries that configure NTFS properties, shown in Table 10.8, in the subkey HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\FileSystem.
Note
- Not all of these entries are present by default. Depending on your operating system and your setup, you might have to create these entries. For information on adding entries to the registry, see "Registry" in this book.
Table 10.8 Registry Entries for NTFS Properties
Registry Entry |
Description |
---|---|
NtfsDisable8dot3NameCreation |
Specifies whether NTFS automatically generates an 8.3 file name for each new file created on the volume. If MS-DOS or Microsoft® Windows® 3.x clients do not need access to the volume, enabling this property can speed up file system activity. |
NtfsAllowExtendedCharacterIn8Dot3Name |
Specifies whether you can use extended characters in short file names. |
NtfsMftZoneReservation |
Specifies the relative size of the master file table (MFT). |
NtfsDisableLastAccessUpdate |
Specifies whether NTFS updates the last-access timestamp on each directory when it lists the directories on an NTFS volume. This property is designed to prevent the NTFS log buffer in physical memory from becoming filled with timestamp update records. If you have an NTFS volume with a very large number of directories (in excess of 70,000) and the operating system does not respond quickly to dir commands, adding this entry to the registry might make directories list faster. |
Win31FileSystem |
Specifies whether the FAT file system uses long file names and extended timestamps. This entry limits the files stored on FAT volumes to using only features found in the FAT file system used in Windows 3.1 and earlier versions. Changing this entry does not change any files, but it does change how the FAT file system displays and manages the files. |
You can use a tool such as Regedit.exe to view these registry entries and their values. Alternatively, you can retrieve this same information using a script. Scripts allow data retrieval to be carried out in an automated fashion. Furthermore, using WMI in the script allows you to retrieve these properties from remote computers as well as from the local computer.
Caution
- Changing the registry with a script can easily propagate errors. The scripting tools bypass safeguards, allowing settings that can damage your system, or even require you to reinstall Windows. Before scripting changes to the registry, test your script thoroughly and back up the registry on every computer on which you will make changes. For more information about scripting changes to the registry, see the Registry Referenceon the Microsoft Windows 2000 Server Resource Kit companion CD or at https://www.microsoft.com/reskit.
Scripting Steps
Listing 10.17 contains a script that enumerates the properties of the NTFS file system that a computer uses. To carry out this task, the script must perform the following steps:
Create a constant named HKEY_LOCAL_MACHINE and set the value to &H80000002. This value is required by the Standard Registry Provider when connecting to the HKEY_LOCAL_MACHINE portion of the registry. (For more information about using the WMI Standard Registry Provider, see "Registry" in this book.)
Create a variable to specify the computer name.
Use a GetObject call to connect to the WMI namespace root\default:StdRegProv on the computer, and set the impersonation level to "impersonate."
Set the variable strValueName to the path within the HKEY_LOCAL_MACHINE portion of the registry. For each value being retrieved, the path is System\CurrentControlSet\Control\FileSystem.
Set the variable strValueName to the name of the first entry from which the value is being retrieved (NtfsDisable8dot3NameCreation).
Use the GetDWORDValue method to read the first registry value. This method requires the following parameters:
HKEY_LOCAL_MACHINE - Constant required to access HKEY_LOCAL_MACHINE.
strKeyPath - Registry path within HKEY_LOCAL_MACHINE.
strValueName - Registry entry being read.
dwValue - Out parameter that will be set to the registry value. For example, if NtfsDisable8dot3NameCreation is equal to 0, then dwValue is also be equal to 0.
Use an If Then construct to evaluate dwValue and echo the appropriate message. For example, if dwValue is 1, the message "No value set for disabling 8.3 file name creation" is echoed to the screen.
Repeat the process with the remaining registry values.
Listing 10.17 Enumerating NTFS Properties
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
|