简体   繁体   中英

Pagefile error with error code “Set-WmiInstance : Value out of range”

I am trying to set pagefile size for C and D drive with the following code. But there is an odd issue with this. Sometimes the code will work perfectly. Sometimes it will throw an error saying

Set-WmiInstance : Value out of range

for both drives. And sometimes it will throw that error only for C or D drive.

Can anyone know the reason?

Note: I test this code in my laptop only.

Set-WmiInstance -Class Win32_PageFileSetting -Arguments @{
    Name        = "C:\pagefile.sys";
    InitialSize = 800;
    MaximumSize = 1600
}
Set-WmiInstance -Class Win32_PageFileSetting -Arguments @{
    Name        = "D:\pagefile.sys";
    InitialSize = 1600;
    MaximumSize = 3200
}

InitialSize Data type: uint32

Access type: Read/write

Qualifiers: MappingStrings ("Win32Registry|System\\CurrentControlSet\\Control\\Session Manager\\Memory Management|PagingFiles"), Units ("megabytes")

MaximumSize Data type: uint32

Access type: Read/write

Qualifiers: MappingStrings ("Win32Registry|System\\CurrentControlSet\\Control\\Session Manager\\Memory Management|PagingFiles"), Units ("megabytes")

Could you please try this once:

Set-WmiInstance Win32_PageFileSetting -Arguments @{Name='D:\pagefile.sys'; InitialSize=128; MaximumSize=512}

I know what is the problem and how to fix it.

  1. Disable Auto Manage PageFile Setting for All drives
  2. Delete Existing Page File
  3. Change the drive to System Manage
  4. Set the pagefile for the drives

These tricks help me to set the pagefile with whatever number I want

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM