Contact Info

Crumbtrail

ActiveXperts.com » Administration » VBScript Collection » Operating System » Page Files

Page File Scripts

List Page File Performance
List Page File Properties
List Page File Use
Modify Page File Properties


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 Page File Performance


Uses cooked performance counters to return page file performance information.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
Set colItems = objRefresher.AddEnum _
    (objWMIService, "Win32_PerfFormattedData_PerfOS_PagingFile").objectSet
objRefresher.Refresh

For i = 1 to 5
    For Each objItem in colItems
        Wscript.Echo "Caption: " & objItem.Caption
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Percent Usage: " & objItem.PercentUsage
        Wscript.Echo "Percent Usage Peak: " & objItem.PercentUsagePeak
        Wscript.Sleep 2000
        objRefresher.Refresh
    Next
Next
	

List Page File Properties


Lists the properties of all the page files on a computer.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPageFiles = objWMIService.ExecQuery("Select * from Win32_PageFile")

For Each objPageFile in colPageFiles
    Wscript.Echo "Creation Date: " & objPageFile.CreationDate
    Wscript.Echo "Description: " & objPageFile.Description
    Wscript.Echo "Drive: " & objPageFile.Drive        
    Wscript.Echo "File Name: " & objPageFile.FileName  
    Wscript.Echo "File Size: " & objPageFile.FileSize  
    Wscript.Echo "Initial Size: " & objPageFile.InitialSize
    Wscript.Echo "Install Date: " & objPageFile.InstallDate
    Wscript.Echo "Maximum Size: " & objPageFile.MaximumSize
    Wscript.Echo "Name: " & objPageFile.Name  
    Wscript.Echo "Path: " & objPageFile.Path  
Next
	

List Page File Use


Retrieves page file usage statistics.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPageFiles = objWMIService.ExecQuery("Select * from Win32_PageFileUsage")

For Each objPageFile in colPageFiles
    Wscript.Echo "Allocated Base Size: " & objPageFile.AllocatedBaseSize
    Wscript.Echo "Current Usage: " & objPageFile.CurrentUsage
    Wscript.Echo "Description: " & objPageFile.Description
    Wscript.Echo "Install Date: " & objPageFile.InstallDate
    Wscript.Echo "Name: " & objPageFile.Name   
    Wscript.Echo "Peak Usage: " & objPageFile.PeakUsage 
Next
	

Modify Page File Properties


Sets the initial size of a page file to 300 megabytes, and the maximum size to 600 megabytes.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colPageFiles = objWMIService.ExecQuery _
    ("Select * from Win32_PageFileSetting")

For Each objPageFile in colPageFiles
    objPageFile.InitialSize = 300
    objPageFile.MaximumSize = 600
    objPageFile.Put_
Next