Configuring Page File Properties

Microsoft® Windows® 2000 Scripting Guide

microsoft windows 2000 scripting guide

« Previous | Next »   

When you install Windows on a computer, the operating system automatically sets up and configures a page file for you. In many cases, those settings will be adequate, and you will never need to reconfigure the page file.

In other cases, however, the settings might prove less than optimal. If a page file is too small, applications might run short on virtual memory. If a page file is too large, you might be wasting disk space that could be used for other purposes. In either case, you can reconfigure the page file settings in order to promote faster and more efficient computing.

You can use the Win32_PageFileSetting class to modify both the initial size and the maximum size of any page file on your computer. Table 10.12 describes the properties of the Win32_PageFileSetting class.

Note

  • You must restart the computer before the new page file settings take effect.

Table 10.12   Win32_PageFileSetting Properties

PropertyDescription
InitialSizeInitial size of the page file, in megabytes.
MaximumSizeMaximum size of the page file, in megabytes.
NamePath and file name of the page file.

Scripting Steps

Listing 10.21 contains a script that configures the page file properties 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_PageFileSetting class.

    This returns a collection of all the page files on the computer.

  4. For each page file in the collection, set the InitialSize to 300 MB and the MaximumSize to 600 MB.
  5. Use the Put_ method to apply the changes and modify the page file settings.

Listing 10.21   Configuring Page File Properties

1 2 3 4 5 6 7 8 9 10 
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


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