Monitoring Page File Use

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

The Win32_PageFileUsage class enables you to obtain basic information about each page file on a computer, including the allocated file size, the current file size, and the largest size the file has reached since the computer started. This class is useful for routine monitoring of each page file.

As long as the maximum size of the file is less than 70 percent of the allocated size, it is generally safe to assume the page file is correctly configured.

Table 10.11 shows some of the key properties of the Win32_PageFileUsage class.

Table 10.11   Win32_PageFileUsage Properties

PropertyDescription
AllocatedBaseSizeActual amount of disk space allocated for use with this page file. This value corresponds to the range established in Win32_PageFileSetting under the InitialSize and MaximumSize properties, set at system startup.
CurrentUsageAmount of disk space currently used by the page file.
DescriptionDescription of the object.
InstallDateDate the page file was created.
NamePath and file name of the page file.
PeakUsageHighest use page file.

Scripting Steps

Listing 10.20 contains a script that monitors page file use on a computer. To carry out this task, the script must perform the following steps:

  1. Create a variable to specify the computer name.
  2. Use a GetObject call to connect to the WMI namespace root\cimv2, and set the impersonation level to "impersonate."
  3. Use the ExecQuery method to query the Win32_PageFileUsage class.

    This returns a collection of statistics for each of the page files on the computer.

  4. For each page file in the collection, echo the value of properties such as the current usage, the peak usage, and the file status.

Listing 10.20   Monitoring Page File Use

1 2 3 4 5 6 7 8 9 10 11 12 13 
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 "CurrentUsage: " & objPageFile.CurrentUsage     Wscript.Echo "Description: " & objPageFile.Description        Wscript.Echo "InstallDate: " & objPageFile.InstallDate        Wscript.Echo "Name: " & objPageFile.Name        Wscript.Echo "PeakUsage: " & objPageFile.PeakUsage    Next

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