Jump to content
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble
Strawberry Orange Banana Lime Leaf Slate Sky Blueberry Grape Watermelon Chocolate Marble

MSFN is made available via donations, subscriptions and advertising revenue. The use of ad-blocking software hurts the site. Please disable ad-blocking software or set an exception for MSFN. Alternatively, register and become a site sponsor/subscriber and ads will be disabled automatically. 


Mikep7779

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.

Share this post


Link to post
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.

Share this post


Link to post
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?

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

You would want to take the code I supplied above and save it to a file with a .vbs extention. Something like PageFile.vbs. Then just make that one of your RunOnceEx entries.

Share this post


Link to post
Share on other sites

It detects how much you have. The 1024 reference is just part of an equation to convert the amount of RAM into a number I could use.

Share this post


Link to post
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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...