Jump to content

How to set pagefile?


Recommended Posts


The Pagefile info is stored here

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management]
"PagingFiles"=your pagefile size and location

Export the reg key and import from cmdlines.txt (untested by me) or after 1st logon, which is what I do, then after next reboot it should be on the drive you want and the size you want.

Link to comment
Share on other sites

Exporting the key from the registry will work, partly. Set the pagefile as you want it in Windows and then export the reg-key (it cannot be set the way you think, by writing it manually).

The pagefile will be set to the size you want, but it will use the absolute path set in the reg-file (for example drive/partition F:\). If you change the partitions the pagefile will not be set correctly. It can also be set using a batch to run pagefileconfig.vbs (in System32).

Edited by DL.
Link to comment
Share on other sites

What I have stored in my registry at:

HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management

"PagingFiles" =hex(7):44,00,3a,00,5c,00,70,00,61,00,67,00,65,00,66,00,69,00,6c,\

00,65,00,2e,00,73,00,79,00,73,00,20,00,31,00,35,00,33,00,36,00,20,00,32,00,\

30,00,34,00,38,00,00,00,00,00

Which is for D:\Pagefile.sys 1536 2048

So using this within a .cmd or such during unattended would preset the pagefile to where you want? Instead of having windows preselect the drive with the amount of space it believes it requires?

Link to comment
Share on other sites

Here is a VBscript I wrote that will set the pagefile to double the size of your system's RAM:

Option Explicit

'Subroutine; Page File configuration
Sub ConfigPageFile
Dim strComputer, objWMIService, objSWbemServices, colPageFile, colSWbemObject
Dim colSWbemObjectSet, objSWbemObject, objPageFile, SystemRAM
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 / 1024
Next
For Each objPageFile In colPageFile
objPageFile.InitialSize = 2 * SystemRAM
objPageFile.MaximumSize = 2 * SystemRAM
objPageFile.Put_
Next
End Sub

ConfigPageFile

Please note that since the script utilizes WMI it cannot be run from cmdlines.txt. Instead this can run from RunOnceEx or GuiRunOnce.

Edited by RogueSpear
Link to comment
Share on other sites

Here are some VBS Scripts for setting the page file

Save As User_Input_PageFile

strComputer = "."

Dim Pmin,Pmax

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

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

Pmin = InputBox("Type In The Minimum Size For The Page File","Min Size")

Pmax = InputBox("Type In The Maximum Size For The Page File","Max Size")

For Each objPageFile in colPageFiles

objPageFile.InitialSize = Pmin

objPageFile.MaximumSize = Pmax

objPageFile.Put_

Next

Here is a script where you fill it in then you run it.

This color Text is where you add your size for the min and mac size

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 = 512

objPageFile.MaximumSize = 512

objPageFile.Put_

Next

Link to comment
Share on other sites

  • 2 years later...

This is my AutoIt script to set the pagefile.

It sets pagefile to a fixed size of twice the system RAM. But it goes a few steps further.

It does a more accurate check of the system RAM. And checks if free space on drive is enough. Otherwise it lets the OS manage the pagefile.

Dim $iSystemRAM
$objWMIService = ObjGet("winmgmts:{ImpersonationLevel=impersonate}!\\localhost\root\CIMV2")
$colPhysicalMemory = $objWMIService.ExecQuery("Select * From Win32_PhysicalMemory")
For $objPhysicalMemory In $colPhysicalMemory
$iSystemRAM += $objPhysicalMemory.Capacity
Next
$iPageFileSize = 2 * $iSystemRAM / (1024 ^ 2)
$colPageFile = $objWMIService.ExecQuery("Select * From Win32_PageFile")
For $objPageFile In $colPageFile
If DriveSpaceFree($objPageFile.Drive & $objPageFile.Path) > 1.5 * ( $iPageFileSize - $objPageFile.FileSize / (1024 ^ 2) ) Then
$sSettingID = $objPageFile.FileName & "." & $objPageFile.Extension & " @ " & $objPageFile.Drive
$colPageFileSetting = $objWMIService.ExecQuery('Select * From Win32_PageFileSetting Where SettingID = "' & $sSettingID & '"')
For $objPageFileSetting In $colPageFileSetting
With $objPageFileSetting
.InitialSize = $iPageFileSize
.MaximumSize = $iPageFileSize
.Put_
EndWith
Next
EndIf
Next

Regards.

Link to comment
Share on other sites

  • 2 months later...

Artbio... I just tried this on two different XP Pro systems with 4 Gig of RAM and they both failed with:

Line-1:

Error: The requested action with this object has failed.

I ran it in a virtual machine and the page file setting changed to the wrong value... any ideas would be really great as this is exactly what I want to do in my integrated installation cd's

THANKS

Link to comment
Share on other sites

Hi compstuff.

You must run this script at a stage of Windows XP Setup where WMI is already installed and fully functional. Otherwise it will return that kind of error. Run it at GuiRunOnce or RunOnceEx and you will be fine.

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...