File Systems Scripts
Enumerating NTFS PropertiesIdentify the File System Type
Modifying File System Properties
Monitoring NTFS File Cache Performance
Enumerating NTFS Properties
Retrieves NTFS file system settings from the registry.
On Error Resume Next Set objShell = WScript.CreateObject("WScript.Shell") strRegKey = objShell.RegRead _ ("HKLM\System\CurrentControlSet\Control\FileSystem\" _ & "NtfsDisable8dot3NameCreation") If IsNull(strRegKey) Then Wscript.Echo "No value set for disabling 8.3 file name creation." ElseIf strRegKey = 1 Then WScript.Echo "No 8.3 file names will be created for new files." ElseIf strRegKey = 0 Then Wscript.Echo "8.3 file names will be created for new files." End If strRegKey = Null strRegKey = objShell.RegRead _ ("HKLM\System\CurrentControlSet\Control\FileSystem\" _ & "NtfsAllowExtendedCharacterIn8Dot3Name") If IsNull(strRegKey) Then Wscript.Echo "No value set for allowing extended characters in " _ & " 8.3 file names." ElseIf strRegKey = 1 Then WScript.Echo "Extended characters are permitted in 8.3 file names." ElseIf strRegKey = 0 Then Wscript.Echo "Extended characters not permitted in 8.3 file names." End If strRegKey = Null strRegKey = objShell.RegRead _ ("HKLM\System\CurrentControlSet\Control\FileSystem\" _ & "NtfsMftZoneReservation") If IsNull(strRegKey) Then Wscript.Echo "No value set for reserving the MFT zone." ElseIf strRegKey = 1 Then WScript.Echo _ "One-eighth of the disk has been reserved for the MFT zone." ElseIf strRegKey = 2 Then Wscript.Echo "One-fourth of the disk reserved for the MFT zone." ElseIf strRegKey = 3 Then Wscript.Echo "Three-eighths of the disk reserved for the MFT zone." ElseIf strRegKey = 4 Then Wscript.Echo "One half of the disk reserved for the MFT zone." End If strRegKey = Null strRegKey = objShell.RegRead _ ("HKLM\System\CurrentControlSet\Control\FileSystem\" _ & "NtfsDisableLastAccessUpdate") If IsNull(strRegKey) Then Wscript.Echo "No value set for disabling the last access update " _ & "for files and folder." ElseIf strRegKey = 1 Then WScript.Echo "The last access timestamp will not be updated on files " _ & "and folders." ElseIf strRegKey = 0 Then Wscript.Echo "The last access timestamp updated on files and " _ & "folders." End If strRegKey = Null strRegKey = objShell.RegRead _ ("HKLM\System\CurrentControlSet\Control\FileSystem\Win31FileSystem") If IsNull(strRegKey) Then Wscript.Echo "No value set for using long file names and " _ & "timestamps." ElseIf strRegKey = 1 Then WScript.Echo "Long file names and extended timestamps are used." ElseIf strRegKey = 0 Then Wscript.Echo "Long file names and extended timestamps are not used." End If
Identify the File System Type
Returns the type of file system (FAT, NTFS, FAT32, etc.) used on each drive in a computer.
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 "DeviceID: "& vbTab & objDisk.DeviceID Wscript.Echo "File System: "& vbTab & objDisk.FileSystem Next
Modifying File System Properties
Disables the updating of the last access time for files and folders.
Set objShell = WScript.CreateObject("WScript.Shell") strRegKey = objShell.RegWrite _ ("HKLM\System\CurrentControlSet\Control\FileSystem\" _ & "NtfsDisableLastAccessUpdate" , 1, "REG_DWORD")
Monitoring NTFS File Cache Performance
Uses cooked performance counters to monitor the performance of the NTFS file cache.
strComputer = "." Set objWMIService = GetObject("winmgmts:" _ & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") set objRefresher = CreateObject("WbemScripting.SWbemRefresher") Set colCache = objRefresher.AddEnum _ (objWMIService, "win32_PerfFormattedData_PerfOS_Cache").ObjectSet objRefresher.Refresh For i = 1 to 100 For Each objCache in colCache Wscript.Echo "Async Copy Reads Per Second" & vbTab & _ objCache.AsyncCopyReadsPerSec Wscript.Echo "Async Data Maps Per Second" & vbTab & _ objCache.AsyncDataMapsPerSec Wscript.Echo "AsyncFastReadsPerSecond" & vbTab & _ objCache.AsyncFastReadsPerSec Wscript.Echo "Async MDL Reads Per Second" & vbTab & _ objCache.AsyncMDLReadsPerSec Wscript.Echo "Async Pin Reads Per Second" & vbTab & _ objCache.AsyncPinReadsPerSec Wscript.Echo "Caption" & vbTab & objCache.Caption Wscript.Echo "Copy Read Hits Percent " & vbTab & _ objCache.CopyReadHitsPercent Wscript.Echo "Copy Reads Per Second" & vbTab & _ objCache.CopyReadsPerSec Wscript.Echo "Data Flushes Per Second" & vbTab & _ objCache.DataFlushesPerSec Wscript.Echo "Data Flush Pages PerSecond" & vbTab & _ objCache.DataFlushPagesPerSec Wscript.Echo "Data Map Hits Percent " & vbTab & _ objCache.DataMapHitsPercent Wscript.Echo "Data Map Pins Per Second" & vbTab & _ objCache.DataMapPinsPerSec Wscript.Echo "Data Maps Per Second" & vbTab & _ objCache.DataMapsPerSec Wscript.Echo "Description" & vbTab & objCache.Description Wscript.Echo "Fast Read Not Possibles Per Second" & vbTab & _ objCache.FastReadNotPossiblesPerSec Wscript.Echo "Fast Read Resource Misses Per Second" & vbTab & _ objCache.FastReadResourceMissesPerSec Wscript.Echo "Fast Reads Per Second" & vbTab & _ objCache.FastReadsPerSec Wscript.Echo "Lazy Write Flushes Per Second" & vbTab & _ objCache.LazyWriteFlushesPerSec Wscript.Echo "Lazy Write Pages Per Second" & vbTab & _ objCache.LazyWritePagesPerSec Wscript.Echo "MDL Read Hits Percent " & vbTab & _ objCache.MDLReadHitsPercent Wscript.Echo "MDL Reads Per Second" & vbTab & _ objCache.MDLReadsPerSec Wscript.Echo "Name" & vbTab & objCache.Name Wscript.Echo "Pin Read Hits Percent" & vbTab & _ objCache.PinReadHitsPercent Wscript.Echo "Pin Reads Per Second" & vbTab & _ objCache.PinReadsPerSec Wscript.Echo "Read Aheads Per Second" & vbTab & _ objCache.ReadAheadsPerSec Wscript.Echo "Sync Copy Reads Per Second" & vbTab & _ objCache.SyncCopyReadsPerSec Wscript.Echo "Sync Data Maps Per Second" & vbTab & _ objCache.SyncDataMapsPerSec Wscript.Echo "Sync Fast Reads Per Second" & vbTab & _ objCache.SyncFastReadsPerSec Wscript.Echo "Sync MDL Reads Per Second" & vbTab & _ objCache.SyncMDLReadsPerSec Wscript.Echo "Sync Pin Reads Per Second" & vbTab & _ objCache.SyncPinReadsPerSec Wscript.Sleep 2000 objRefresher.Refresh Next Next