Skip to content
向野而深的博客
Go back

Windows C 盘深度清理全攻略

目录

个人Windows C 盘深度清理记录

C 盘空间不足确实让人头疼,尤其是对于需要配置各种开发环境和处理大型项目的用户。除了常规的“清空回收站”,以下是针对 Windows 系统最有效且安全的深度清理方案:

1. 核心清理工具:系统自带“磁盘清理”

不要只用普通模式,管理员模式可以清理更多的系统冗余。

  1. Win + R,输入 cleanmgr 并回车。

  2. 选择 C 盘,点击确定。

  3. 关键步骤:点击左下角的 “清理系统文件”

  4. 必勾选项:

    • Windows 更新清理(通常有几个 GB,是旧版本的备份)。

    • 传递优化文件

    • 设备驱动程序软件包

  5. 点击确定并删除。


2. 深度扫描:手动清理大文件

有些占用空间巨大的文件隐藏在缓存路径中,可以手动定位:

移除休眠文件

  • 以管理员身份运行 CMD,输入:powercfg -h off

清理用户缓存 (Temp)

  • Win + R,输入 %temp%,删除文件夹内所有内容(正在运行的无法删除,跳过即可)。

3. 使用工具分析并手动清理

WizTree 扫描占用分布,结合AI 询问大容量文件是否可以删除。

有效果,可以尝试……

4. 开发环境与软件专项清理

以管理员身份运行bat脚本

基础删除脚本,clean-c.bat

@echo off
setlocal enabledelayedexpansion

:: Check for Administrator Privileges
net session >nul 2>&1
if %errorLevel% neq 0 (
    echo [ERROR] Please run this script as ADMINISTRATOR.
    pause
    exit /b
)

echo ===========================================
echo   Windows System Cleanup Tool
echo ===========================================

:: 1. User Temp Files
echo [+] Cleaning User Temporary Files...
del /f /s /q "%temp%\*.*" >nul 2>&1
for /d %%i in ("%temp%\*") do rd /s /q "%%i" >nul 2>&1

:: 2. System Temp Files
echo [+] Cleaning System Temporary Files...
del /f /s /q "%systemroot%\Temp\*.*" >nul 2>&1
for /d %%i in ("%systemroot%\Temp\*") do rd /s /q "%%i" >nul 2>&1

:: 3. Windows Update Cache
:: Stopping the service is necessary to unlock the Download folder
echo [+] Cleaning Windows Update Cache...
net stop wuauserv >nul 2>&1
del /f /s /q "%systemroot%\SoftwareDistribution\Download\*.*" >nul 2>&1
net start wuauserv >nul 2>&1

:: 4. Prefetch & Thumbnails
echo [+] Cleaning Prefetch and Thumbnail Cache...
del /f /s /q "%systemroot%\Prefetch\*.*" >nul 2>&1
del /f /s /q "%LocalAppData%\Microsoft\Windows\Explorer\thumbcache_*.db" >nul 2>&1

:: 5. System Logs (Via Event Viewer)
echo [+] Clearing System Setup and System Logs...
wevtutil cl Setup >nul 2>&1
wevtutil cl System >nul 2>&1

echo ===========================================
echo   Cleanup Task Completed successfully!
echo ===========================================
pause

针对docker、node、android 等环境,clean-code.bat

@echo off
setlocal

echo ===========================================
echo   Developer Environment Cleanup Tool
echo ===========================================

:: 1. Node.js - npm cache
echo [+] Cleaning npm cache...
call npm cache clean --force >nul 2>&1

:: 2. Node.js - pnpm store (If used)
:: pnpm store prune removes unreferenced packages from the store
echo [+] Pruning pnpm store...
call pnpm store prune >nul 2>&1

:: 3. Node.js - Yarn cache (If used)
echo [+] Cleaning Yarn cache...
call yarn cache clean >nul 2>&1

:: 4. Android Studio - Gradle Cache
:: This is usually the biggest offender (located in %USERPROFILE%\.gradle)
echo [+] Cleaning Gradle caches (this may take a while)...
if exist "%USERPROFILE%\.gradle\caches" (
    rd /s /q "%USERPROFILE%\.gradle\caches" >nul 2>&1
    echo     - Gradle caches removed.
)

:: 5. Android Studio - Android SDK Temp & Build-tools
echo [+] Cleaning Android SDK temporary files...
if exist "%LOCALAPPDATA%\Android\Sdk\temp" (
    rd /s /q "%LOCALAPPDATA%\Android\Sdk\temp" >nul 2>&1
)

:: 6. Docker Desktop (Optional but high impact)
:: This command removes all unused containers, networks, and images
echo [+] Pruning Docker system (containers, images, networks)...
docker system prune -f >nul 2>&1

:: 7. Visual Studio Code - Cache & Service Worker
echo [+] Cleaning VS Code Cache...
if exist "%APPDATA%\Code\Cache" rd /s /q "%APPDATA%\Code\Cache" >nul 2>&1
if exist "%APPDATA%\Code\CachedData" rd /s /q "%APPDATA%\Code\CachedData" >nul 2>&1

echo ===========================================
echo   Developer Cleanup Completed!
echo ===========================================
pause

目前这些方法可以节省 10G 空间

(完)



Previous Post
Windows 环境下 pyenv-win 全指南
Next Post
MacOS 清理神器 Mole 使用教程