Contact Info

Crumbtrail

ActiveXperts.com » Administration » VBScript Collection » Storage » Files

File Management using VBScript

List the File System Type
List NTFS Properties
Modify File System Properties
Monitor NTFS File Cache Performance


You can use any of the VBScript programs below in ActiveXperts Network Monitor. Click here for an explanation about how to include scripts in ActiveXperts Network Monitor.



List the File System Type


Identifies the file system in use for each logical disk on 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 "Device ID: "& vbTab &  objDisk.DeviceID       
    Wscript.Echo "File System: "& vbTab & objDisk.FileSystem
Next
	

List 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
	

Modify 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")
	

Monitor 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" & _
            objCache.AsyncCopyReadsPerSec
        Wscript.Echo "Async Data Maps Per Second" & _
            objCache.AsyncDataMapsPerSec
        Wscript.Echo "AsyncFastReadsPerSecond" & _
            objCache.AsyncFastReadsPerSec
        Wscript.Echo "Async MDL Reads Per Second" & _
            objCache.AsyncMDLReadsPerSec
        Wscript.Echo "Async Pin Reads Per Second" & _
            objCache.AsyncPinReadsPerSec
        Wscript.Echo "Caption" & vbTab & objCache.Caption
        Wscript.Echo "Copy Read Hits Percent " & _
            objCache.CopyReadHitsPercent
        Wscript.Echo "Copy Reads Per Second" & _
            objCache.CopyReadsPerSec
        Wscript.Echo "Data Flushes Per Second" & _
            objCache.DataFlushesPerSec
        Wscript.Echo "Data Flush Pages Per Second" & _
            objCache.DataFlushPagesPerSec
        Wscript.Echo "Data Map Hits Percent " & _
            objCache.DataMapHitsPercent
        Wscript.Echo "Data Map Pins Per Second" & _
            objCache.DataMapPinsPerSec
        Wscript.Echo "Data Maps Per Second" & _
            objCache.DataMapsPerSec
        Wscript.Echo "Description" & objCache.Description
        Wscript.Echo "Fast Read Not Possibles Per Second" & _
            objCache.FastReadNotPossiblesPerSec
        Wscript.Echo "Fast Read Resource Misses Per Second" & _
            objCache.FastReadResourceMissesPerSec
        Wscript.Echo "Fast Reads Per Second" & _
            objCache.FastReadsPerSec
        Wscript.Echo "Lazy Write Flushes Per Second" & _
            objCache.LazyWriteFlushesPerSec
        Wscript.Echo "Lazy Write Pages Per Second" & _
            objCache.LazyWritePagesPerSec
        Wscript.Echo "MDL Read Hits Percent " & _
            objCache.MDLReadHitsPercent
        Wscript.Echo "MDL Reads Per Second" & _
            objCache.MDLReadsPerSec
        Wscript.Echo "Name" & vbTab & objCache.Name
        Wscript.Echo "Pin Read Hits Percent" & _
            objCache.PinReadHitsPercent
        Wscript.Echo "Pin Reads Per Second" & _
            objCache.PinReadsPerSec
        Wscript.Echo "Read Aheads Per Second" & _
            objCache.ReadAheadsPerSec
        Wscript.Echo "Sync Copy Reads Per Second" & _
            objCache.SyncCopyReadsPerSec
        Wscript.Echo "Sync Data Maps Per Second" & _
            objCache.SyncDataMapsPerSec
        Wscript.Echo "Sync Fast Reads Per Second" & _
            objCache.SyncFastReadsPerSec
        Wscript.Echo "Sync MDL Reads Per Second" & _
            objCache.SyncMDLReadsPerSec
        Wscript.Echo "Sync Pin Reads Per Second" & _
            objCache.SyncPinReadsPerSec
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next