前言
默认情况下,Windows Server2008/2008R2/2012/2012R2 中不存在磁盘清理可执行文件cleanmgr.exe和关联的磁盘清理按钮。(Win2016默认是安装了磁盘清理cleanmgr服务)
启用cleanmgr
那么如何启用磁盘清理工具:
转到“程序和功能”,然后在“功能”部分中,启用/安装 “桌面体验(Desktop Experience)”。 这样做的缺点是,你需要在安装后重新启动服务器,并在服务器上安装其他不需要的组件。
[推荐] - 如果你的系统不是Windows Server 2012 R2 ,那么你真正需要做的就是将服务器上已有的一些文件复制到特定的系统文件夹中(找不到可以默认全局搜一下cleanmgr)
为了使用cleanmgr.exe,你需要复制服务器上已存在的两个文件,cleanmgr.exe和cleanmgr.exe.mui。参考下表查找操作系统的文件。
Operating System | Architecture | File Location |
---|---|---|
Windows Server 2008 R2 | 64bit | C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.1.7600.16385_none_c9392808773cd7da\cleanmgr.exe |
Windows Server 2008 R2 | 64bit | C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.1.7600.16385_en-us_b9cb6194b257cc63\cleanmgr.exe.mui |
Windows Server 2008 | 64bit | C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.0.6001.18000_en-us_b9f50b71510436f2\cleanmgr.exe.mui |
Windows Server 2008 | 64bit | C:\Windows\winsxs\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.0.6001.18000_none_c962d1e515e94269\cleanmgr.exe |
Windows Server 2008 | 32bit | C:\Windows\winsxs\x86_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.0.6001.18000_en-us_5dd66fed98a6c5bc\cleanmgr.exe.mui |
Windows Server 2008 | 32bit | C:\Windows\winsxs\x86_microsoft-windows-cleanmgr_31bf3856ad364e35_6.0.6001.18000_none_6d4436615d8bd133\cleanmgr.exe |
Windows Server 2012 | 64bit | C:\Windows\WinSxS\amd64_microsoft-windows-cleanmgr_31bf3856ad364e35_6.2.9200.16384_none_c60dddc5e750072a\cleanmgr.exe |
Windows Server 2012 | 64bit | C:\Windows\WinSxS\amd64_microsoft-windows-cleanmgr.resources_31bf3856ad364e35_6.2.9200.16384_en-us_b6a01752226afbb3\cleanmgr.exe.mui |
找到文件后,将它们移动到以下位置(Server 2012非R2及更早版本):
将Cleanmgr.exe复制 到 %systemroot%\System32.
将Cleanmgr.exe.mui复制 到 %systemroot%\System32\zh-CN.
现在可以通过 从命令提示符运行Cleanmgr.exe来启动磁盘清理工具。
注意:Windows Server 2012 R2 必须安装”桌面体验”。使用Powershell命令
PS> Install-WindowsFeature Desktop-Experience
参考链接
Disk Cleanup on Windows Server 2008 Without Installing Desktop Experience
How to enable the Disk Cleanup tool on Windows Server 2008 R2