Jump to content

Scripting the Page File


Recommended Posts

I hope someone finds this useful. I wrote a subroutine in VBscript to set the page file. It creates a page file that is twice the amount of RAM in your system.

'**********************************************************************

'** Subroutine; Page File configuration                              **

'**********************************************************************

Sub ConfigPageFile

Dim strComputer, objWMIService, objSWbemServices, colPageFile, colSWbemObjectSet

Dim objSWbemObject, SystemRAM, objPageFile

strComputer = "."

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set objSWbemServices = GetObject("winmgmts:\\" & strComputer)

Set colPageFile = objWMIService.ExecQuery ("SELECT * FROM Win32_PageFileSetting")

Set colSWbemObjectSet = objSWbemServices.InstancesOf("Win32_LogicalMemoryConfiguration")

For Each objSWbemObject In colSWbemObjectSet

     SystemRAM = objSWbemObject.TotalPhysicalMemory / 1000

Next

For Each objPageFile In colPageFile

  objPageFile.InitialSize = 2 * SystemRAM

  objPageFile.MaximumSize = 2 * SystemRAM

  objPageFile.Put_

Next

End Sub

Link to comment
Share on other sites


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...