Here is one way you can get the system to automatically delete the pagefile.sys on shutdown in Windows 10. To set this up, you’ll be making changes to the Windows registry. This should be safe, but to be super-safe, you should back up your Windows 10 registry before starting.
How Windows Clears the Pagefile
When you make Windows automatically clear the pagefile with every shutdown, it will actually overwrite the existing pagefile data with “zeros.” This makes it near impossible to recover data from the pagefile. However, because of the rewriting process, the time to shut down your system may increase.
Delete Pagefile using Registry Editor
Open the Windows 10 registry editor by pressing Win+ R, then entering regedit in the box.
In the registry editor, go to:
Click “Memory Management,” and then double-click on “ClearPageFileAtShutDown” in the panel on the right.
Set its value to “1” and restart the PC. Every time you shut down your PC, the pagefile will be deleted. Don’t worry – it will be created again when needed.
Delete Pagefile using Windows Group Policy Editor
If you are using the Pro or Enterprise version of Windows, then you can use the Group Policy Editor to clear the pagefile automatically. To start, search for gpedit.msc in the Start menu and open it.
The above action will open the Group Policy Editor. Here, navigate to “Computer Configuration -> Windows Settings -> Security Settings -> Local Policies -> Security Options” on the left panel.
On the right panel, find and double-click on the “Shutdown: Clear virtual memory page file” policy.
In the policy settings window, select the “Enabled” radio option, and then click on the “OK” button to save the changes.
Then just restart your system to make the changes take effect and you are good to go. If you ever want to revert back, simply select the “Disabled” radio option in the policy settings window. If this tip has given you some confidence in the Windows registry, then you can find this and more in our list of Windows registry hacks. We also have a guide on how to edit another user’s registry in Windows 10.