C盘空间清理脚本 C Drive Cleanup Script

无需安装 · 代码透明 · 自主掌控 · 释放10-50GB No Install · Open Source · You Control · Free 10-50GB >

中文版

简体中文
无需安装
纯脚本 无捆绑
代码可见
公开透明
自主掌控
随时可停
可释放空间
10GB - 50GB
⚠️ 必须以管理员身份运行 ⚠️ Must Run as Administrator
1. 右键点击「开始菜单」→ 选择「命令提示符 (管理员)」或「Windows 终端 (管理员)」
2. 复制下方脚本,粘贴到 CMD 窗口中按回车执行
1. Right-click Start Menu → Select "Command Prompt (Admin)" or "Windows Terminal (Admin)"
2. Copy the script below, paste into CMD window and press Enter
@echo off
chcp 65001 >nul
title C盘空间清理脚本
color 0A
setlocal enabledelayedexpansion

echo ==============================================
echo  【C盘空间清理脚本】请以管理员身份运行cmd.exe, 然后粘贴此脚本
echo  脚本代码公开透明,无任何风险和病毒
echo  清理完成可释放10GB~50GB空间
echo ==============================================
echo.

:: 1. 停止Windows更新服务
echo 正在停止Windows更新服务...
net stop wuauserv >nul 2>&1
net stop cryptSvc >nul 2>&1
net stop bits >nul 2>&1
net stop msiserver >nul 2>&1
echo 已完成
echo.

:: 2. 清理Windows更新下载缓存
echo 正在清理Windows更新缓存...
del /q /f /s "%windir%\SoftwareDistribution\Download\*.*" >nul 2>&1
del /q /f /s "%windir%\SoftwareDistribution\DataStore\Logs\*.*" >nul 2>&1
echo 已完成
echo.

:: 3. 清理系统临时文件+用户临时文件
echo 正在清理临时文件...
del /q /f /s "%temp%\*.*" >nul 2>&1
del /q /f /s "%windir%\temp\*.*" >nul 2>&1
echo 已完成
echo.

:: 4. 关闭休眠文件(释放内存大小空间)
echo 正在关闭休眠功能...
powercfg -h off >nul 2>&1
echo 已完成
echo.

:: 5. 清理系统错误报告、日志、更新残留
echo 正在清理系统日志和错误报告...
del /q /f /s "%windir%\Logs\*.*" >nul 2>&1
del /q /f /s "%windir%\System32\LogFiles\*.*" >nul 2>&1
del /q /f /s "%programdata%\Microsoft\Windows\WER\ReportArchive\*.*" >nul 2>&1
del /q /f /s "%programdata%\Microsoft\Windows\WER\ReportQueue\*.*" >nul 2>&1
echo 已完成
echo.

:: 6. 清理浏览器缓存(Chrome/Edge/IE/QQ/360/搜狗/傲游)
echo 正在清理浏览器缓存...
:: Chrome
if exist "%localappdata%\Google\Chrome\User Data\Default\Cache" (
    del /f /s /q "%localappdata%\Google\Chrome\User Data\Default\Cache\*.*" >nul 2>&1
    del /f /s /q "%localappdata%\Google\Chrome\User Data\Default\Code Cache\*.*" >nul 2>&1
)
:: Edge
if exist "%localappdata%\Microsoft\Edge\User Data\Default\Cache" (
    del /f /s /q "%localappdata%\Microsoft\Edge\User Data\Default\Cache\*.*" >nul 2>&1
    del /f /s /q "%localappdata%\Microsoft\Edge\User Data\Default\Code Cache\*.*" >nul 2>&1
)
:: IE/旧版Edge
del /f /s /q "%localappdata%\Microsoft\Windows\INetCache\*.*" >nul 2>&1
:: QQ浏览器
if exist "%localappdata%\Tencent\QQBrowser\Default\Cache" (
    del /f /s /q "%localappdata%\Tencent\QQBrowser\Default\Cache\*.*" >nul 2>&1
    del /f /s /q "%localappdata%\Tencent\QQBrowser\Default\Data\*.*" >nul 2>&1
)
:: 360浏览器
if exist "%localappdata%\360Chrome\Chrome\User Data\Default\Cache" (
    del /f /s /q "%localappdata%\360Chrome\Chrome\User Data\Default\Cache\*.*" >nul 2>&1
)
:: 搜狗浏览器
if exist "%localappdata%\SogouExplorer\WebKit\Cache" (
    del /f /s /q "%localappdata%\SogouExplorer\WebKit\Cache\*.*" >nul 2>&1
)
:: 傲游浏览器
if exist "%localappdata%\Maxthon5\Cache" (
    del /f /s /q "%localappdata%\Maxthon5\Cache\*.*" >nul 2>&1
)
echo 已完成
echo.

:: 7. 清理微信/QQ默认C盘缓存
echo 正在清理微信/QQ文件缓存...
if exist "%userprofile%\Documents\WeChat Files" (
    del /q /f /s "%userprofile%\Documents\WeChat Files\*\FileStorage\File\*.*" >nul 2>&1
    del /q /f /s "%userprofile%\Documents\WeChat Files\*\FileStorage\Image\*.*" >nul 2>&1
)
if exist "%userprofile%\Documents\Tencent Files" (
    del /q /f /s "%userprofile%\Documents\Tencent Files\*\FileRecv\*.*" >nul 2>&1
)
echo 已完成
echo.

:: 8. 清理系统更新卸载文件(WinSxS临时文件)
echo 正在清理WinSxS临时文件(可能需要较长时间)...
takeown /f "%windir%\WinSxS" /r /d y >nul 2>&1
icacls "%windir%\WinSxS" /grant %username%:F /t >nul 2>&1
del /q /f /s "%windir%\WinSxS\Temp\*.*" >nul 2>&1
echo 已完成
echo.

:: 9. 运行磁盘清理工具(自动清理C盘)
echo 正在启动磁盘清理工具(自动清理C盘)...
cleanmgr /verylowdisk /d C: >nul 2>&1
echo 已完成
echo.

:: 10. 重启Windows更新服务
echo 正在重启Windows更新服务...
net start wuauserv >nul 2>&1
net start cryptSvc >nul 2>&1
net start bits >nul 2>&1
net start msiserver >nul 2>&1
echo 已完成
echo.

:: 11. 关闭系统还原(删除所有卷影副本)
echo 正在清理系统还原点(释放大量空间)...
vssadmin delete shadows /all /quiet >nul 2>&1
wmic computersystem set AutomaticManagedPageFile=False >nul 2>&1
wmic pagefileset delete >nul 2>&1
echo 已完成
echo.

:: ========== 安全附加步骤 ==========

:: 12. 清理 Windows.old(旧系统备份)
echo ========== 清理 Windows.old 旧系统文件 ==========
if exist "C:\Windows.old" (
    echo 发现 Windows.old 文件夹,正在删除(可能需要几分钟)...
    takeown /f C:\Windows.old /r /d y >nul 2>&1
    icacls C:\Windows.old /grant %username%:F /t >nul 2>&1
    rd /s /q C:\Windows.old >nul 2>&1
    echo 已完成,Windows.old 已删除。
) else (
    echo 未找到 Windows.old,跳过。
)
echo.

:: 13. 重建 Windows 搜索索引
echo ========== 重建搜索索引 ==========
echo 重建索引可释放空间,但首次搜索会变慢。
set /p idx_choice="是否重建搜索索引?(y/n): "
if /i "%idx_choice%"=="y" (
    echo 正在停止 Windows 搜索服务...
    net stop wsearch >nul 2>&1
    
    echo 正在删除索引数据库文件...
    del /f /s /q "%programdata%\Microsoft\Search\Data\Applications\Windows\Windows.edb" >nul 2>&1
    
    echo 正在重启搜索服务(后台重建索引)...
    net start wsearch >nul 2>&1
    echo 已完成,索引已重建。
) else (
    echo 跳过索引重建。
)
echo.

:: 14. 禁用预留存储(Windows 10/11)
echo ========== 禁用预留存储 ==========
for /f "tokens=*" %%a in ('dism /Online /Get-ReservedStorageState ^| find "State"') do set state=%%a
echo 当前预留存储状态:%state%
set /p rs_choice="是否禁用预留存储?禁用后可释放约7GB空间(需重启生效)(y/n): "
if /i "%rs_choice%"=="y" (
    echo 正在禁用预留存储...
    dism /Online /Set-ReservedStorageState /State:Disabled >nul 2>&1
    echo 已完成,重启后生效。
) else (
    echo 跳过预留存储设置。
)
echo.

:: ========== 清理完成 ==========
echo ==============================================
echo  ✅ C盘清理完成!已释放大量空间
echo  建议:将微信/QQ的文件保存路径迁移到其他盘
echo  部分修改需重启系统才能完全生效
echo ==============================================
pause
exit /b
>

English Version

English
No Install
Pure Script
Open Source
You Can Verify
You Control
Stop Anytime
Space to Free
10GB - 50GB
⚠️ 必须以管理员身份运行 ⚠️ Must Run as Administrator
1. 右键点击「开始菜单」→ 选择「命令提示符 (管理员)」或「Windows 终端 (管理员)」
2. 复制下方脚本,粘贴到 CMD 窗口中按回车执行
1. Right-click Start Menu → Select "Command Prompt (Admin)" or "Windows Terminal (Admin)"
2. Copy the script below, paste into CMD window and press Enter
@echo off
chcp 65001 >nul
title C Drive Cleanup Script
color 0A
setlocal enabledelayedexpansion

echo ==============================================
echo  [C Drive Cleanup Script] Run as Administrator in cmd.exe, then paste this script
echo  Script is open and transparent, no risks or viruses
echo  Can free up 10GB~50GB after completion
echo ==============================================
echo.

:: 1. Stop Windows Update services
echo Stopping Windows Update services...
net stop wuauserv >nul 2>&1
net stop cryptSvc >nul 2>&1
net stop bits >nul 2>&1
net stop msiserver >nul 2>&1
echo Done.
echo.

:: 2. Clean Windows Update cache
echo Cleaning Windows Update cache...
del /q /f /s "%windir%\SoftwareDistribution\Download\*.*" >nul 2>&1
del /q /f /s "%windir%\SoftwareDistribution\DataStore\Logs\*.*" >nul 2>&1
echo Done.
echo.

:: 3. Clean system & user temp files
echo Cleaning temporary files...
del /q /f /s "%temp%\*.*" >nul 2>&1
del /q /f /s "%windir%\temp\*.*" >nul 2>&1
echo Done.
echo.

:: 4. Disable hibernation (frees up RAM-sized space)
echo Disabling hibernation...
powercfg -h off >nul 2>&1
echo Done.
echo.

:: 5. Clean system error reports, logs, update leftovers
echo Cleaning system logs and error reports...
del /q /f /s "%windir%\Logs\*.*" >nul 2>&1
del /q /f /s "%windir%\System32\LogFiles\*.*" >nul 2>&1
del /q /f /s "%programdata%\Microsoft\Windows\WER\ReportArchive\*.*" >nul 2>&1
del /q /f /s "%programdata%\Microsoft\Windows\WER\ReportQueue\*.*" >nul 2>&1
echo Done.
echo.

:: 6. Clean browser caches (Chrome/Edge/IE/QQ/360/Sogou/Maxthon)
echo Cleaning browser caches...
:: Chrome
if exist "%localappdata%\Google\Chrome\User Data\Default\Cache" (
    del /f /s /q "%localappdata%\Google\Chrome\User Data\Default\Cache\*.*" >nul 2>&1
    del /f /s /q "%localappdata%\Google\Chrome\User Data\Default\Code Cache\*.*" >nul 2>&1
)
:: Edge
if exist "%localappdata%\Microsoft\Edge\User Data\Default\Cache" (
    del /f /s /q "%localappdata%\Microsoft\Edge\User Data\Default\Cache\*.*" >nul 2>&1
    del /f /s /q "%localappdata%\Microsoft\Edge\User Data\Default\Code Cache\*.*" >nul 2>&1
)
:: IE/old Edge
del /f /s /q "%localappdata%\Microsoft\Windows\INetCache\*.*" >nul 2>&1
:: QQ Browser
if exist "%localappdata%\Tencent\QQBrowser\Default\Cache" (
    del /f /s /q "%localappdata%\Tencent\QQBrowser\Default\Cache\*.*" >nul 2>&1
    del /f /s /q "%localappdata%\Tencent\QQBrowser\Default\Data\*.*" >nul 2>&1
)
:: 360 Browser
if exist "%localappdata%\360Chrome\Chrome\User Data\Default\Cache" (
    del /f /s /q "%localappdata%\360Chrome\Chrome\User Data\Default\Cache\*.*" >nul 2>&1
)
:: Sogou Browser
if exist "%localappdata%\SogouExplorer\WebKit\Cache" (
    del /f /s /q "%localappdata%\SogouExplorer\WebKit\Cache\*.*" >nul 2>&1
)
:: Maxthon Browser
if exist "%localappdata%\Maxthon5\Cache" (
    del /f /s /q "%localappdata%\Maxthon5\Cache\*.*" >nul 2>&1
)
echo Done.
echo.

:: 7. Clean WeChat / QQ default C drive cache
echo Cleaning WeChat/QQ file cache...
if exist "%userprofile%\Documents\WeChat Files" (
    del /q /f /s "%userprofile%\Documents\WeChat Files\*\FileStorage\File\*.*" >nul 2>&1
    del /q /f /s "%userprofile%\Documents\WeChat Files\*\FileStorage\Image\*.*" >nul 2>&1
)
if exist "%userprofile%\Documents\Tencent Files" (
    del /q /f /s "%userprofile%\Documents\Tencent Files\*\FileRecv\*.*" >nul 2>&1
)
echo Done.
echo.

:: 8. Clean WinSxS temporary files
echo Cleaning WinSxS temporary files (may take a while)...
takeown /f "%windir%\WinSxS" /r /d y >nul 2>&1
icacls "%windir%\WinSxS" /grant %username%:F /t >nul 2>&1
del /q /f /s "%windir%\WinSxS\Temp\*.*" >nul 2>&1
echo Done.
echo.

:: 9. Run Disk Cleanup tool (automatic C drive)
echo Starting Disk Cleanup tool (auto clean C: drive)...
cleanmgr /verylowdisk /d C: >nul 2>&1
echo Done.
echo.

:: 10. Restart Windows Update services
echo Restarting Windows Update services...
net start wuauserv >nul 2>&1
net start cryptSvc >nul 2>&1
net start bits >nul 2>&1
net start msiserver >nul 2>&1
echo Done.
echo.

:: 11. Disable System Restore (delete all shadow copies)
echo Cleaning System Restore points (frees lots of space)...
vssadmin delete shadows /all /quiet >nul 2>&1
wmic computersystem set AutomaticManagedPageFile=False >nul 2>&1
wmic pagefileset delete >nul 2>&1
echo Done.
echo.

:: ========== Additional safe steps ==========

:: 12. Clean Windows.old (old system backup)
echo ========== Cleaning Windows.old ==========
if exist "C:\Windows.old" (
    echo Found Windows.old folder, deleting (may take a few minutes)...
    takeown /f C:\Windows.old /r /d y >nul 2>&1
    icacls C:\Windows.old /grant %username%:F /t >nul 2>&1
    rd /s /q C:\Windows.old >nul 2>&1
    echo Done, Windows.old removed.
) else (
    echo Windows.old not found, skipping.
)
echo.

:: 13. Rebuild Windows Search index
echo ========== Rebuild Search Index ==========
echo Rebuilding index frees space but first search will be slower.
set /p idx_choice="Rebuild search index? (y/n): "
if /i "%idx_choice%"=="y" (
    echo Stopping Windows Search service...
    net stop wsearch >nul 2>&1
    
    echo Deleting index database file...
    del /f /s /q "%programdata%\Microsoft\Search\Data\Applications\Windows\Windows.edb" >nul 2>&1
    
    echo Restarting search service (background reindexing)...
    net start wsearch >nul 2>&1
    echo Done, index rebuilt.
) else (
    echo Skipping index rebuild.
)
echo.

:: 14. Disable Reserved Storage (Windows 10/11)
echo ========== Disable Reserved Storage ==========
for /f "tokens=*" %%a in ('dism /Online /Get-ReservedStorageState ^| find "State"') do set state=%%a
echo Current reserved storage state: %state%
set /p rs_choice="Disable reserved storage? Frees about 7GB (requires reboot) (y/n): "
if /i "%rs_choice%"=="y" (
    echo Disabling reserved storage...
    dism /Online /Set-ReservedStorageState /State:Disabled >nul 2>&1
    echo Done, will take effect after reboot.
) else (
    echo Skipping reserved storage.
)
echo.

:: ========== Cleanup finished ==========
echo ==============================================
echo  ✅ C Drive Cleanup Complete!
echo  Suggestion: Move WeChat/QQ save paths to other drives
echo  Some changes require restart to take full effect
echo ==============================================
pause
exit /b
>