The Categorizer

the categorizer logo

Change PageFile Size in Windows using CMD (Batch Script)


Command Prompt Batch Script (.bat file)

1. Without User Input

wmic computersystem where name="%computername%" set AutomaticManagedPageFile=false
wmic pagefileset where name="C:\\pagefile.sys" set InitialSize="add-minimum-pagefile-size", MaximumSize="add-maximum-pagefile-size"

NOTE: Replace the “add-minimum-pagefile-size” and “add-maximum-pagefile-size” with their respective values.

2. With User Input

@REM Scripts Library - TheCategorizer.com

@echo off

@REM Input the Desired PageFile Size (Minimum)
echo Input Minimum PageFile Size
set /p min_size= ""

@REM Input the Desired PageFile Size (Maximum)
echo Input Maximum PageFile Size
set /p max_size= ""

@REM Setting PageFile Size in Windows based on previous inputs
wmic computersystem where name="%computername%" set AutomaticManagedPageFile=false
wmic pagefileset where name="C:\\pagefile.sys" set InitialSize="%min_size%", MaximumSize="%max_size%"

pause

NOTE: Copy and paste the script into a text document, change its file extension from “.txt” to “.bat“, save the file, and run it as an administrator.


More Scripts


More Articles