您的 Windows 系统使用页面文件(Page file)( pagefile.sys ) 作为虚拟内存。它作为一种额外的RAM工作。分页文件提高了系统的性能和速度,但有些用户更喜欢修改(some users prefer to modify)它的工作方式。这是因为您无法随时确定Windows将哪些数据保存在Pagefile.sys中。页面文件可能包含密码等敏感数据,即使重新启动后也不会从系统中删除。
这里的危险是任何用户都可以通过导航到 C 驱动器并获得不受限制的访问来访问此文件。未经授权的用户、服务器上的其他操作系统以及网络上的其他设备也可以将其复制到他们的存储设备并进行分析。
Windows系统正确地保护了页面文件,因为错误配置或删除它可能会带来更大的风险。但是,您可以选择保护页面文件中的数据。我们将在本指南中探讨这些选项。
在Windows中关闭时备份、移动(Move)或删除 PageFile.sys(Delete PageFile.sys)
您可以按照此页面上提供的操作过程,而不是从您的计算机系统中明确删除页面文件。以下是我们将在本指南中介绍的阶段:
- 初步阶段:备份(Back)您的文件。
- (Delete)从文件资源管理器中(File Explorer)删除页面文件。
- 替代方法:将页面文件移动到不同的驱动器
- 推荐:将您的计算机设置为在每次关机时删除Pagefile.sys
其中一些程序只能由经验丰富的技术人员处理。但是,我会将它们分解,以便任何人都可以遵循指南,无论您的技术经验如何。
1] 初步阶段:备份(Back)您的文件
分页文件很重要,可以提高系统性能,但如果你坚持要删除它,我建议你先备份你的文件,这样如果删除 pagefile.sys 出现问题,你可以很容易地恢复你的文件。
有多种方法可以备份您的 Windows 计算机。连接硬盘或DVD等外部存储介质,然后按照以下快速方法进行操作。
选择开始(Start)按钮并搜索 控制面板(Control Panel)。打开控制面板并转到 System and Security > Backup and Restore。在此之后,请执行以下步骤之一:
- 如果您最近升级了 Windows 版本或者这是您第一次进行备份,请单击设置备份(Set up backup)并按照向导中的屏幕说明进行操作。
- 如果您过去进行过备份,请单击 立即备份(Back up now)选项。
- 如果这不是您的第一次备份,但您想创建新备份,请选择 创建新的完整备份(Create new, full backup)选项并按照向导中的屏幕步骤进行操作。
2]从文件资源管理器中(File Explorer)删除(Delete)页面文件
首先,打开文件资源管理器(File Explorer)。您可以通过按 Windows key + E快速完成此操作。
单击“ 查看”(View)菜单并转到“ 选项(Options)” 。
取消 选中隐藏受保护的操作系统文件(推荐)(Hide protected operating system files (Recommended))复选框。
在 隐藏文件和文件夹(Hidden files and folders)下,选择 显示隐藏文件、文件夹和驱动器(Show hidden files, folders, and drives)选项并点击 确定(OK)按钮。
分页文件是受保护的系统文件。因此(Hence),它是隐藏的。上述步骤使您可以在Windows 资源管理器(Windows Explorer)中查看此文件。之后,您现在可以删除文件了。
导航 This PC > Local Disk (C:)。
您将在此处找到 pagefile.sys文件。右键单击此文件并单击 Delete。
由于页面文件的大小(the Page file’s size),它很可能不会进入回收站(Recycle Bin)而是被完全删除。这就是为什么备份阶段很重要。
请注意(Notice),Windows 将其归类为 系统文件(System file)。这意味着它对您的计算机的顺利运行至关重要。因此,系统可能不允许您删除它。
您可以在Windows Explorer(Windows Explorer)中查看页面文件(pagefile.sys),但如果您尝试删除它,系统可能会说另一个程序正在使用它。
2]替代方案:将页面文件移动到不同的驱动器
您可以将计算机设置为在新位置创建新的 pagefile.sys 文件,而不是从系统中删除页面文件。此解决方案最适合您拥有与硬盘驱动器性能匹配或超过其性能的其他驱动器的情况。
按Windows key + I组合打开设置。
在这里,转到 System > About。接下来,单击 “相关设置 (Related settings )”区域下的“系统信息 (System info )”链接。
选择左侧窗格中的高级系统设置选项。(Advanced system settings)
切换到“ 高级(Advanced)”选项卡,然后单击“性能” (Performance )区域下的“设置”(Settings)按钮。
在“性能选项(Performance Options)”窗口中,单击“高级(Advanced )”选项卡,您将在“虚拟(Virtual)内存”部分看到分页文件的大小。点击此处的更改(Change)按钮。
取消选中 自动管理所有驱动器的分页文件大小(Automatically manage paging file size for all drives)复选框。
单击 C: [System]驱动器,然后选择此驱动器,然后向下选择 无分页文件(No paging file)选项。点击 设置(Set)按钮。
返回驱动器并选择要存储页面文件的卷。
向下滚动,单击驱动器 的系统管理大小,然后单击(System managed size)设置(Set)按钮。最后,单击提示上的 Yes 按钮。
您已成功禁用主驱动器上的页面文件。但是,我不建议您这样做,因为禁用分页文件后,如果出现系统错误,系统将不再创建故障转储。
下一步是选择要存储页面文件的驱动器。在同一屏幕上,单击此驱动器并选择 系统管理大小(System managed size),而不是 像我们为驱动器 C 所做的那样选择无分页文件。(No paging file)
点击设置(Set)按钮,然后点击 应用(Apply)和 确定(Ok)关闭保存设置并关闭窗口。
最后,重启你的机器。
阅读(Read):如何在 Windows中重置虚拟内存或页面文件
将您的计算机设置为在每次关机时删除Pagefile.sys
知道页面文件对您的机器至关重要,您不想在没有它的情况下运行您的计算机。
但是,页面文件会带来安全风险,因为即使在您重新启动计算机后它也会继续存在。更好的方法是将您的计算机系统设置为在关闭时删除页面文件(set your computer system to delete the paging file whenever it shuts down)。
使用这些方法,您的计算机会在您关闭它时删除页面文件,并且在每次重新启动时,Windows都会创建一个新的页面文件。
注意:(NOTE:)在每次关机时删除页面文件并在启动时创建一个新页面文件会减慢关机和启动时间。
When the Clear virtual memory pagefile setting is turned on, when the system shuts down, the computer may take longer to shut down than it usually takes. This behavior occurs because when this policy setting is turned on, the computer must physically write to each page in the pagefile to clear each page. The period of time that it takes for the system to clear the pagefile varies according to the pagefile size, and the disk hardware that is involved.
1]终极Windows Tweaker
下载并使用我们的免费软件Ultimate Windows Tweaker,只需单击一下即可。您将在Customization > File Explorer下看到该设置。
2]使用注册表编辑器
按 Windows key + R打开“运行”(Run)对话框。在运行(Run)中,键入 Regedit并单击 确定(OK)。
在注册表编辑器(Registry Editor)中,导航到以下文件夹:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management
在右侧窗格中,双击名为ClearPageFileAtShutdown的(ClearPageFileAtShutdown)DWORD并将(DWORD)值数据(Value data) 更改 为 1。点击 OK 按钮保存更改。
注意:(NOTE: )如果您没有找到此DWORD,请右键单击空白区域并从New > DWORD (32-bit) Value中创建它。将名称设置为 ClearPageFileAtShutdown并将值数据设置为 1。
退出注册表编辑器(Registry Editor)并重新启动计算机。
3]使用组策略编辑器
Windows key + R组合打开“运行”(Run)对话框。
在“运行”(Run)对话框中输入 gpedit.msc并按 ENTER(ENTER)。
在组策略编辑器中,展开左侧窗格中的计算机配置。(Computer Configuration)
在计算机配置(Computer Configuration)下,转至Windows Settings > Security Settings > Local Policies > Security Options。
在右侧窗格中,右键单击Shutdown: Clear virtual memory pagefile并选择 Properties。
从新窗口中 选择 启用,最后点击(Enabled)应用 (Apply )和 确定(OK)按钮保存配置。
同样(Again),我不能过分强调删除页面文件可能对您的计算机有害。但是,如果您有充分的理由这样做,请按照上述指南正确执行。
Back up, Move, or Delete PageFile.sys on shutdown in Windows 11/10
Yoυr Windows system uses the Page file (pagefile.sys) for virtual memory. It works as an extra RAM of sorts. The paging file improves your system’s performance and speed, but some users prefer to modify how it works. This is because you can’t be sure of what data Windows saves in Pagefile.sys at any time. The paging file could hold sensitive data such as passwords, and it doesn’t get deleted from your system even after a restart.
The danger here is that any user can access this file by navigating to the C drive and gaining unrestricted access to it. Unauthorized users, other operating systems on your server, and other devices on your network can also copy it out to their storage device and analyze it.
The Windows system rightly protects the paging file because misconfiguring or deleting it can pose a greater risk. However, you have options for protecting your data on the paging file. We’ll explore these options in this guide.
Back up, Move, or Delete PageFile.sys on shutdown in Windows
Instead of explicitly deleting the paging file off your computer system, you can follow the course of action proffered on this page. Here are the phases we’ll cover in this guide:
- Preliminary phase: Back up your files.
- Delete the paging file from File Explorer.
- Alternative: Move the paging file to a different drive
- Recommended: Set your computer to delete Pagefile.sys on every shutdown
Some of these procedures should be handled only by experienced techies. However, I’ll break them down so that anyone can follow the guide, regardless of your technical experience.
1] Preliminary phase: Back up your files
The paging file is crucial and improves your system’s performance, but if you insist on deleting it, I advise that you back up your files first, so that you can easily restore your files if deleting the pagefile.sys causes issues.
There are several ways to back up your Windows computer. Connect an external storage media such as a hard disk or DVD and follow the quick method below.
Select the Start button and search for Control Panel. Open the Control Panel and go to System and Security > Backup and Restore. After this, follow one of the below steps:
- If you recently upgraded your Windows version or it’s your first time making a backup, click on Set up backup and follow the on-screen instructions in the wizard.
- If you’ve made a backup in the past, click the Back up now option.
- If it’s not your first backup, but you want to create a new backup, choose the Create new, full backup option and follow the on-screen steps in the wizard.
2] Delete the paging file from File Explorer
First, open File Explorer. You can do this quickly by pressing the Windows key + E.
Click on the View menu and go to Options.
Unmark the Hide protected operating system files (Recommended) checkbox.
Under Hidden files and folders, select the Show hidden files, folders, and drives option and hit the OK button.
The paging file is a protected system file. Hence, it’s hidden. The steps above enable you to view this file in Windows Explorer. Following that, you’re now ready to delete the file.
Navigate to This PC > Local Disk (C:).
You’ll find the pagefile.sys file here. Right-click on this file and hit Delete.
Due to the Page file’s size, it most likely wouldn’t go to the Recycle Bin but be deleted entirely. That’s why the backing up phase is important.
Notice that Windows classifies it as a System file. Meaning that it’s crucial to the smooth operation of your computer. Therefore, the system may not let you delete it.
You can view the paging file (pagefile.sys) in Windows Explorer, but if you try to delete it, the system may say that another program is using it.
2] Alternative: Move the paging file to a different drive
Instead of deleting the paging file from your system, you can set your computer to create a new pagefile.sys file in a new location. This solution is best suited for cases where you have a different drive that matches or tops the performance of your hard drive.
Press the Windows key + I combination to open Settings.
Here, go to System > About. Next, click on the System info link under the Related settings area.
Select the Advanced system settings option on the left-hand pane.
Switch to the Advanced tab and click on the Settings button under the Performance area.
In the Performance Options window, click on the Advanced tab, and you’ll see the size of your paging file in the Virtual memory section. Hit the Change button here.
Unmark the checkbox for Automatically manage paging file size for all drives.
Click on the C: [System] drive, and with this selected, go down and choose the No paging file option. Hit the Set button.
Go back to the Drives and select the volume to which you want to store the paging file.
Scroll down, click on the System managed size for the drive, and hit the Set button. Finally, click on the Yes button on the prompt.
You have successfully disabled the paging file on your primary drive. However, I don’t advise that you do this because, with the paging file disabled, the system will no longer create crash dumps if there’s a system error.
The next step is to choose the drive on which you wish to store the paging file. From this same screen, click on this drive and select System managed size instead of No paging file as we did for drive C.
Hit the Set button and click Apply and Ok to close save your settings and close the window.
Finally, restart your machine.
Read: How to reset Virtual Memory or Page File in Windows
Set your computer to delete Pagefile.sys on every shutdown
Knowing that the page file is vital to your machine, you don’t want to run your computer without it.
However, the paging file poses a security risk because it’s carried over even after you restart your machine. A better way is to set your computer system to delete the paging file whenever it shuts down.
With these methods, your computer deletes the paging file whenever you shut it down, and on each restart, Windows creates a fresh paging file.
NOTE: Deleting the paging file on every shutdown and creating a new one on startup will slow down your shutdown and booting times.
When the Clear virtual memory pagefile setting is turned on, when the system shuts down, the computer may take longer to shut down than it usually takes. This behavior occurs because when this policy setting is turned on, the computer must physically write to each page in the pagefile to clear each page. The period of time that it takes for the system to clear the pagefile varies according to the pagefile size, and the disk hardware that is involved.
1] Ultimate Windows Tweaker
Download and use our freeware Ultimate Windows Tweaker to do so with a click. You will see the setting under Customization > File Explorer.
2] Using the Registry Editor
Press the Windows key + R to open the Run dialog box. In Run, type Regedit and click OK.
In the Registry Editor, navigate to the following folder:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Memory Management
On the right-hand pane, double-click on the DWORD named ClearPageFileAtShutdown and change the Value data to 1. Hit the OK button to save the changes.
NOTE: If you don’t find this DWORD, right-click on the white space and create it from New > DWORD (32-bit) Value. Set the name to ClearPageFileAtShutdown and the Value data to 1.
Exit Registry Editor and restart your computer.
3] Using Group Policy Editor
Open the Run dialog box by pressing the Windows key + R combination.
Input gpedit.msc in the Run dialog box and hit ENTER.
In the Group Policy Editor, expand Computer Configuration on the left-hand pane.
Under Computer Configuration, go to Windows Settings > Security Settings > Local Policies > Security Options.
From the right-hand pane, right-click on Shutdown: Clear virtual memory pagefile and select Properties.
Choose Enabled from the new window and finally hit the Apply and OK buttons to save the configuration.
Again, I can’t overemphasize that deleting the paging file can be detrimental to your computer. However, if you have good reasons to do so, do it properly by following the above guide.