0

So one of the applications that we use is consistently crashing whenever it is processing a larger amount of data than it usually does, so to mitigate this I found a fix for it where I can manually increase the paging file size of the windows 10 OS. I've attached screenshots of what I accessed and what values I've changed. Is there any way to have the same thing done with a power shell script? There are a lot of people in my department who most likely won't want to go through the process of navigating control panel and manually changing these values.

Is there a power shell script that can manually edit the virtual memory pop-up and change it from the checkbox that says "Automatically manage paging file size for all drives" to setting it to the custom size radio button, and inputting value 12000 for initial size and value 32000 for maximum size? These options can be found by typing "Adjust the performance and appearance of windows" on the search bar, navigating to the advanced tab, and finally clicking change under virtual memory. I know this is a bit of an unorthodox request but any help on this would be really appreciated. Thanks!

enter image description here

  • Does this answer your question? [PowerShell Script to set the size of pagefile.sys](https://stackoverflow.com/questions/37813441/powershell-script-to-set-the-size-of-pagefile-sys) – 7cc Jun 05 '20 at 12:51

2 Answers2

1

According to this answer on a similar question:

You can modify registry in order to change pagefile settings.

They are stored in the following registry's key:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management

PagingFiles value contains values in the 'PageFileLocation MinSize MaxSize' format (i.e. 'C:\pagefile.sys 1024 2048')...

and it's possible to create or modify registry entries with PowerShell (see "Example 2: Create a registry entry and value").

According to a comment on the same answer, there's also a method of modifying the values using WMI. A Google search yielded this Microsoft documentation on the Win32_PageFileSetting class, which you can interface with using PowerShell.

Eric Reed
  • 377
  • 1
  • 6
  • 21
0

PowerShell

# Run as administrator
# Step1. Disalbe AutomaticManagedPagefile
$ComputerSystem = Get-WmiObject -ClassName Win32_ComputerSystem
$ComputerSystem.AutomaticManagedPagefile = $false
$ComputerSystem.Put()

# Step2. Set Pagefile Size
$PageFileSetting = Get-WmiObject -ClassName Win32_PageFileSetting
$PageFileSetting.InitialSize = 12000
$PageFileSetting.MaximumSize = 32000
$PageFileSetting.Put()

CMD.exe / Bat

:: Run as administrator
wmic COMPUTERSYSTEM set AutomaticManagedPagefile=false
wmic PAGEFILESET set InitialSize=12000,MaximumSize=32000
7cc
  • 1,149
  • 4
  • 10