当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 如何在 Windows Server 2016/2012 R2/2008 R2 上运行磁盘清理 (Cleamgr.exe)?

作者:精品下载站 日期:2024-12-14 20:09:17 浏览:16 分类:玩电脑

如何在 Windows Server 2016/2012 R2/2008 R2 上运行磁盘清理 (Cleamgr.exe)?


磁盘清理工具允许管理员通过删除不必要的临时文件来快速清理Windows Server系统驱动器,包括清理WinSxS目录中安装最新累积更新后残留的过时组件的文件。默认情况下,磁盘清理实用程序 (cleanmgr.exe) 安装在 Windows Server 2016/2019(桌面体验)的 GUI 版本上。但是,在以前版本的 Windows Server(2012 R2/2012/2008 R2)中,缺少 cleanmgr.exe 工具。

在 Windows Server 2016 上使用磁盘清理工具

要使用磁盘清理实用程序清理 Windows Server 2016 上系统磁盘上不需要的文件,您需要在文件资源管理器中打开磁盘属性,然后单击磁盘清理按钮。

[玩转系统] 如何在 Windows Server 2016/2012 R2/2008 R2 上运行磁盘清理 (Cleamgr.exe)?

您还可以输入“

disk cleanup”

或者

cleanmgr.exe

在搜索框中。

选择您要清理的驱动器。

[玩转系统] 如何在 Windows Server 2016/2012 R2/2008 R2 上运行磁盘清理 (Cleamgr.exe)?

等待清理向导检查您的磁盘并找到可以安全删除的不需要的文件。

[玩转系统] 如何在 Windows Server 2016/2012 R2/2008 R2 上运行磁盘清理 (Cleamgr.exe)?

您可以选择可以删除文件的组件。系统会提示您删除以下临时文件:

  • 设置日志文件;

  • 下载的程序文件;

  • 临时网络文件;

  • 回收站;

  • 临时文件;

  • 缩略图。

要删除不需要的系统文件,请单击清理系统文件按钮。

[玩转系统] 如何在 Windows Server 2016/2012 R2/2008 R2 上运行磁盘清理 (Cleamgr.exe)?

此外,建议清理:

  • 过时的 Windows Defender 文件;

  • 系统存档的 Windows 错误报告文件(文件夹 C:\ProgramData\Microsoft\Windows\WER\ReportQueue);

  • 系统排队 Windows 错误报告;

  • 设备驱动程序包(请参阅如何从驱动程序存储中删除未使用的驱动器);

  • Windows 更新清理 — 这允许您清理 WinSxS 目录中的组件存储。安装更新后保留的旧版本组件文件将被删除。

[玩转系统] 如何在 Windows Server 2016/2012 R2/2008 R2 上运行磁盘清理 (Cleamgr.exe)?

选择您需要的选项,磁盘清理将显示您分配的磁盘空间量。单击“确定”并确认删除文件。

[玩转系统] 如何在 Windows Server 2016/2012 R2/2008 R2 上运行磁盘清理 (Cleamgr.exe)?

等待cleanmgr.exe工具删除不需要的文件。

Cleanmgr.exe:磁盘清理命令行选项

cleanmgr.exe

该工具有多个命令行选项,可用于各种自动驱动器清洁场景。它们既可以在 Windows Server 上使用,也可以在运行 Windows 10 的用户桌面工作站上使用。

cleanmgr.exe [/d driveletter] [/SAGESET:n | /SAGERUN:n | TUNEUP:n | /LOWDISK | /VERYLOWDISK | /SETUP | /AUTOCLEAN]

[玩转系统] 如何在 Windows Server 2016/2012 R2/2008 R2 上运行磁盘清理 (Cleamgr.exe)?

/AUTOCLEAN

参数用于删除升级 Windows 版本后留下的旧文件。

/SETUP

选项允许您删除以前版本的 Windows 留下的文件(如果您执行了就地升级)。

cleanmgr /LOWDISK

命令使用已选择的清理选项运行磁盘清理 GUI。

[玩转系统] 如何在 Windows Server 2016/2012 R2/2008 R2 上运行磁盘清理 (Cleamgr.exe)?

cleanmgr /VERYLOWDISK

命令执行自动驱动器清理(不显示 GUI),结束后它会显示有关所执行操作和可用空间的信息。

You have successfully resolved the low disk space condition. Your C:\ volume now has 10000 Mb of free space remaining.

[玩转系统] 如何在 Windows Server 2016/2012 R2/2008 R2 上运行磁盘清理 (Cleamgr.exe)?

使用

/sageset:xx

/sagerun:xx

选项,您可以创建并运行一组自定义的清理选项。

例如,运行命令:

cleanmgr /sageset: 11

。在打开的窗口中,选择要自动清理的组件和文件(我选择了所有选项)。

这些设置保存到注册表项HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches。此注册表部分列出了可以使用磁盘清理工具清理的所有 Windows 组件。对于您选择的每个选项,都会创建一个名为 StateFlags0011 的 DWORD 参数(

0011 

是您在 sageset 参数中指定的数字)。

[玩转系统] 如何在 Windows Server 2016/2012 R2/2008 R2 上运行磁盘清理 (Cleamgr.exe)?

要使用选定的参数启动驱动器清理任务,请运行以下命令:

cleanmgr /sagerun:11

如果您需要在Active Directory域中的计算机(或服务器)上配置自动磁盘清理任务,只需导出此注册表项并通过GPO将其部署到计算机上即可。

要自动清理 Windows 10 工作站上的系统驱动器,您可以使用以下 PowerShell 代码创建一个简单的计划任务:

Start-Process -FilePath CleanMgr.exe -ArgumentList '/sagerun:11' -WindowStyle Hidden -Wait

如何在不安装桌面体验的情况下在 Windows Server 2012 R2/2008 R2 上启用磁盘清理?

默认情况下,在 Windows Server 2012/R2 和 2008/R2 中,默认情况下不会安装磁盘清理 (cleanmgr.exe) 工具。要使用 cleanmgr 实用程序,首先必须使用服务器管理器或 PowerShell 安装单独的服务器桌面体验功能(

Install-WindowsFeature Desktop-Experience

)。

除了桌面体验之外,服务器上还安装了许多其他不必要的组件:

  • Windows媒体播放器;

  • 桌面主题;

  • Windows 的 AVI 支持;

  • Windows 边秀;

  • Windows Defender 防病毒软件;

  • 磁盘清理;

  • 同步中心;

  • 声音录制;

  • 字符映射表;

  • 截图工具。

[玩转系统] 如何在 Windows Server 2016/2012 R2/2008 R2 上运行磁盘清理 (Cleamgr.exe)?

要在Windows Server上运行磁盘清理,可以使用一个简单的方法:只需将两个文件Cleamgr.exeCleanmgr.exe.mui从WinSxS复制到system32目录即可。下面您可以看到在不同 Windows 版本中复制 cleanmgr 文件的命令(在所有情况下,该路径都用于 Windows Server 英语版本)。

OS versionCommand to copy cleanmgr bin filesWindows Server 2008 R2 x64

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe C:\Windows\System32\
copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui C:\Windows\System32\en-US\
Windows Server 2008 x64

copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.0.6001.18000_none_c962d1e515e94269\cleanmgr.exe C:\Windows\System32\
copy C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.0.6001.18000_en-us_b9f50b71510436f2\cleanmgr.exe.mui C:\Windows\System32\en-US\
Windows Server 2012 x64

copy C:\Windows\WinSxS\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.2.9200.16384_none_c60dddc5e750072a\cleanmgr.exe C:\Windows\System32\
copy C:\Windows\WinSxS\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.2.9200.16384_en-us_b6a01752226afbb3\cleanmgr.exe.mui C:\Windows\System32\en-US\

Windows Server 2012 R2 x64

由于 KB2821895 更新所做的更改,上述技巧在 Windows Server 2012 R2 上不起作用。问题是,安装此更新后,将使用压缩来存储二进制组件文件。当您尝试运行复制的 cleanmgr.exe 时,出现以下错误:

Unsupported 16-Bit Application

The Program or feature \??\C:\Windows\system32\cleanmgr.exe cannot start or run due to incompatibility with 64-bit version of Windows.

[玩转系统] 如何在 Windows Server 2016/2012 R2/2008 R2 上运行磁盘清理 (Cleamgr.exe)?

作为解决方法,您可以使用此方法:

  1. 使用 PowerShell 安装桌面体验功能:

     Install-WindowsFeature Desktop-Experience
  2. 重新启动你的服务器;

  3. 复制文件 %windir%\system3

  4. 卸载该功能:

    Uninstall-WindowsFeature Desktop-Experience
  5. 重启;

  6. 将文件 cleanmgr.exe 和 cleanmgr.exe.mui 复制到上述目录。

稍后,这两个文件都可以复制到其他服务器或集成到 Windows Server 2012 R2 虚拟机模板中。

要启动磁盘清理工具,请运行

cleanmgr.exe

具有管理员权限的命令。

[玩转系统] 如何在 Windows Server 2016/2012 R2/2008 R2 上运行磁盘清理 (Cleamgr.exe)?

dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase

要在Windows 2008 R2/Windows 7 SP1上使用cleanmgr.exe删除旧的更新文件,您需要安装单独的补丁KB2852386。

在 Windows Server Core Edition 上使用磁盘清理

在Windows Server Core 2016中,缺乏成熟的GUI功能,也没有安装磁盘清理工具。如果要使用cleanmgr.exe清理Server Core上的磁盘,只需从WinSXS目录中复制以下文件:

copy C:\Windows\WinSxS\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_10.0.14393.0_none_9ab8a1dc743e759a\cleanmgr.exe C:\Windows\System32\copy C:\Windows\WinSxS\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_10.0.14393.0_en-us_8b4adb68af596a23\cleanmgr.exe.mui C:\Windows\System32\en-US\

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯