Enumerating NTFS Properties

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

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 EntryDescription
NtfsDisable8dot3NameCreationSpecifies 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.
NtfsMftZoneReservationSpecifies 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 Reference on the Microsoft Windows 2000 Server Resource Kit companion CD or at http://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:

  1. 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.)
  2. Create a variable to specify the computer name.
  3. Use a GetObject call to connect to the WMI namespace root\default:StdRegProv on the computer, and set the impersonation level to "impersonate."
  4. 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.
  5. Set the variable strValueName to the name of the first entry from which the value is being retrieved (NtfsDisable8dot3NameCreation).
  6. 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.
  7. 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.
  8. 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 
Const HKEY_LOCAL_MACHINE = &H80000002 strComputer = "." Set objRegistry = GetObject _     ("winmgmts:{impersonationLevel=impersonate}!\\" & _          strComputer & "\root\default:StdRegProv") strKeyPath = "System\CurrentControlSet\Control\FileSystem" strValueName = "NtfsDisable8dot3NameCreation" objRegistry.GetDWORDValue _     HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue If IsNull(dwValue) Then     Wscript.Echo "No value set for disabling 8.3 file name creation." ElseIf dwValue = 1 Then     WScript.Echo "No 8.3 file names will be created for new files." ElseIf dwValue = 0 Then     Wscript.Echo "8.3 file names will be created for new files." End If strValueName = "NtfsAllowExtendedCharacterIn8Dot3Name" objRegistry.GetDWORDValue _     HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue If IsNull(dwValue) Then     Wscript.Echo "No value set for allowing extended characters in " _        & " 8.3 file names." ElseIf dwValue = 1 Then     WScript.Echo "Extended characters are permitted in 8.3 file names." ElseIf dwValue = 0 Then     Wscript.Echo "Extended characters not permitted in 8.3 file names." End If strValueName = "NtfsMftZoneReservation" objRegistry.GetDWORDValue _     HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue If IsNull(dwValue) Then     Wscript.Echo "No value set for reserving the MFT zone." ElseIf dwValue = 1 Then     WScript.Echo _         "One-eighth of the disk has been reserved for the MFT zone." ElseIf dwValue = 2 Then     Wscript.Echo "One-fourth of the disk reserved for the MFT zone." ElseIf dwValue = 3 Then     Wscript.Echo "Three-eighths of the disk reserved for the MFT zone." ElseIf dwValue = 4 Then     Wscript.Echo "One half of the disk reserved for the MFT zone." End If strValueName = "NtfsDisableLastAccessUpdate" objRegistry.GetDWORDValue _     HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue If IsNull(dwValue) Then     Wscript.Echo "No value set for disabling the last access update " _         & "for files and folder." ElseIf dwValue = 1 Then     WScript.Echo _          "The last access timestamp will not be updated on files " _               & "and folders." ElseIf dwValue = 0 Then     Wscript.Echo "The last access timestamp updated on files and " _          & "folders." End If strValueName = "Win31FileSystem" objRegistry.GetDWORDValue _     HKEY_LOCAL_MACHINE,strKeyPath,strValueName,dwValue If IsNull(dwValue) Then     Wscript.Echo "No value set for using long file names and " _         & "timestamps." ElseIf dwValue = 1 Then     WScript.Echo "Long file names and extended timestamps are used." ElseIf dwValue = 0 Then     Wscript.Echo "Long file names and extended timestamps are not used." End If

send us your feedback Send us your feedback « Previous | Next »   


Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
Microsoft Windows 2000 Scripting Guide(c) Automating System Administration 2003
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 635

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net