WMI Pagefile Script
I recently needed a script to create a 200MB pagefile on C:\ (for dump purposes) and a 6144MB pagefile on D:\ for my virtual machine template. Here’s a touch of WMI to handle the job.
‘************************* Systems ArchiTECH *************************
‘****************** www.SystemsArchiTECH.com ************************
‘ Author: Jason M. Langone
‘ Description:
‘ This script shall create a 200MB pagefile on C:\ and a 6144MB pagefile on D:\ as per the virtual machine standard
‘const HKEY_LOCAL_MACHINE = &H80000002
‘strComputer = “.”
‘Set objReg = GetObject(“winmgmts:\\” & strComputer & “\root\default:StdRegProv”)
‘strKeyPath = “SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management”
‘objReg.CreateKey HKEY_LOCAL_MACHINE, strKeyPath
‘ValueName = “PagingFiles”
‘strValue = “c:\pagefile.sys 200 200 “ & VBNullChar & “d:\pagefile.sys 6144 6144”
Const HKEY_LOCAL_MACHINE = &H80000002
strComputer = “.”
Set oReg=GetObject(“winmgmts:{impersonationLevel=impersonate}!\\” & _ strComputer & “\root\default:StdRegProv”)
strKeyPath = “SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management”
strValueName = “PagingFiles”
arrStringValues = Array(“c:\pagefile.sys 200 200”, “d:\pagefile.sys 6144 6144”)
oReg.SetMultiStringValue HKEY_LOCAL_MACHINE,strKeyPath, _ strValueName,arrStringValues
Commenting is closed for this article.

2007 Systems Architech.