how to completely disable pagefile use wmic

Hi I am trying to create a batch file to disable the page file on windows 7, is there any wmic command will do this? I know I should be able to use

"wmic pagefileset delete"

however this always give me the error no instance(s) available, any example would be great, many thanks!


When you want to change your page file settings you need to first turn the automatic pagefile off and after that make a new pagefile with your own defined settings. In the Windows Management Instrumentation (WMI) the automatic pagefile and the set page file have different aliasses: The automatically managed pagefile can be 'managed' through the pagefile alias. Since everything is managed automatically there's only a view command you can use in the following way:

wmic pagefile

or

wmic pagefile list /format:list

(I prefer the last one since it has output in a more humanly viewable format)

The selfmanaged pagefile can be managed through the pagefileset alias. Before you can set a pagefile however, you need to disable the automatic pagefile. The command for this is:

wmic computersystem where name="%computername%" set AutomaticManagedPagefile=False

After that you can use the pagefileset command to set a pagefile, to create a pagefile, to delete a pagefile... basically all the stuff you want to do with a pagefile. For instance: to create a pagefile to replace the C:\pagefile.sys with a fixed size of 2048 Megabyte, (I don't know why the Step-by-Step guide mentions bytes... the command obviously measures in MegaBytes) simply type:

wmic pagefileset where name="C:\\pagefile.sys" set InitialSize=2048,MaximumSize=2048

After setting the pagefile yourself, you can check its settings with:

wmic pagefileset

or

wmic pagefileset list /format:list    

(Obviously I prefer the latter one again)

To make the settings take effect you need to reboot.

Source