Portable, safe Windows C-drive slimming and long-term protection toolkit (Windows 10 / 11, incl. 24H2). 一款便携、安全的 Windows C 盘瘦身与长效保护工具箱(Windows 10 / 11,含 24H2)。
Looking for a pure-English readme? See README_EN.md. 需要纯英文说明?请看 README_EN.md。
Every user-facing name in this project is bilingual (English / 中文): the CLI menu, the GUI
buttons, the confirm dialogs and the final summaries. Step-by-step progress lines stay in
Chinese to keep the output readable — see Language policy.
本项目的所有用户可见名称均为中英双语(CLI 菜单、GUI 按钮、确认对话框、完成总结)。逐行过程日志保留中文以保持输出简洁,详见语言策略。
- Back up your important data first / 运行前请先备份重要数据. Migrations move real files (Desktop / Documents / Downloads …), so make a backup before running anything / 迁移涉及桌面/文档/下载等真实文件移动,请先备份。
- Scripts are unsigned / 脚本未签名. Windows SmartScreen / Microsoft Defender may block the
.bat/.ps1files. When prompted, choose "More info → Run anyway / 更多信息 → 仍要运行". Running them is at your own risk / 运行未知脚本风险自负.- Requirements / 运行要求: Windows 10 / 11; run the
.batas Administrator / 以管理员身份运行; the target drive must have free space ≥ the data to be migrated / 目标盘剩余空间 ≥ 待迁移数据量.
Moves the space-hungry parts of C: onto a data drive (default D:) without losing anything,
then sets up long-term protection so C: does not fill up again.
把 C 盘上占用空间大的内容无损迁移到目标盘(默认 D:),并做长效保护防止再次被填满。
- Move large Program Files apps to the data drive (junction — apps keep working) / 迁移大型 Program Files 程序(目录联接 junction,程序照常运行)
- Redirect large AppData folders (lossless link) / 重定向大型 AppData 文件夹(无损链接)
- Move user shell folders (Desktop / Documents / Downloads / Pictures / Videos …) / 移动用户文件夹(桌面/文档/下载/图片/视频…)
- Move removable Microsoft Store apps / 迁移可移动的 Microsoft Store 应用
- Drain package-manager caches (npm / pnpm / uv / pip) — folders are kept, never deleted / 抽干包管理器缓存(npm/pnpm/uv/pip)—— 只清内容,文件夹保留
- Drain every TEMP location, including the ones redirected to the data drive / 抽干全部 TEMP,含已迁移到数据盘的部分
- One-time debloat of built-in Microsoft apps (safe whitelist only) / 精简预装 Microsoft 应用(仅安全白名单) Never runs automatically / 绝不会在自动流程中执行 — see "Safety rules" below.
- Long-term protection: Storage Sense, TEMP redirect, scheduled tasks / 长效保护:存储感知、TEMP 重定向、计划任务
- Never delete the source first. The order is always
copy → verify → re-point the link → only then remove the old copy. If any step fails, the original data is left untouched. / 绝不先删源:统一采用「先拷贝 → 校验 → 重指链接 → 最后才删旧副本」,任何一步失败都保留原始数据。 - Never damage the system.
HKLM\ProgramFilesDiris never modified (Microsoft states this breaks Windows Update); system / OEM / license packages are never touched. / 绝不损坏系统:不改HKLM\ProgramFilesDir(微软明确说明会破坏 Windows Update),不碰系统/OEM/授权包。 - Never follow a junction when deleting. After a migration,
C:paths are links into the data drive;Remove-Item -Recursewould delete the real data behind them. All deletion goes throughCS-SafeRemoveTreeincommon.ps1, which refuses to traverse links. / 删除绝不穿透 junction:迁移后 C 盘路径是指向数据盘的链接,Remove-Item -Recurse会删掉链接后的真实数据。所有删除统一走common.ps1的CS-SafeRemoveTree,它拒绝穿透链接。 - Cleanup must not break other software. TEMP and cache folders are drained, never deleted (a missing
%TEMP%breaks countless apps), a 1-day age guard protects files an installer just wrote, and*-updaterfolders are kept because they are updater binaries, not caches. / 清理不能让别的软件失效:TEMP 与缓存目录只「抽干」不删除(缺失%TEMP%会导致大量软件异常);1 天天龄保护避免删掉正在安装的程序刚写入的文件;*-updater是更新程序本体而非缓存,默认保留。 - Always confirm first. Locked files are only force-closed after an explicit bilingual confirmation; user-folder migration always warns that a reboot is required. / 运行前必提示:涉及占用文件会先弹出双语确认;用户文件夹迁移后会提示需要重启。
- Release
C:space as soon as it is safe. After a verified migration the<name>.origbackup is deleted automatically once it is confirmed byte-identical to the data-drive copy — no duplicate leftovers. / 迁移完即释放 C 盘:迁移成功后,C 盘上作为备份保留的「<名称>.orig」会在校验与数据盘完全一致后自动删除,绝不留下重复副本。 - App removal is never automatic (v1.5.0). Uninstalling software is destructive and visible, so the one-click flows (
-Auto, menu A, GUI one-click button) never remove apps:debloat.ps1does nothing in-Automode unless you also pass-AllowAppRemoval. Run Debloat from the menu to see exactly what was found and confirm first. Removing the provisioned copy (installed for every new profile) is harder to undo, so it stays off unless you pass-StripProvisioned. / 绝不自动删应用(v1.5.0):卸载软件是破坏性且用户可见的操作,因此一键流程(-Auto、菜单 A、GUI 一键按钮)绝不删应用;debloat.ps1在-Auto下必须再加-AllowAppRemoval才会执行。需要精简请从菜单运行「Debloat」,会列出清单并先确认。移除 provisioned 副本(影响新建用户)更难恢复,默认不执行,需显式-StripProvisioned。 - Administrator is required and actually checked (v1.5.0). The
.batlaunchers request elevation automatically. If a.ps1is run directly without elevation it stops with a clear message, instead of failing halfway and still reporting success. / 必须管理员且会真实检查(v1.5.0):.bat启动器会自动提权;若直接运行.ps1而没提权,脚本会明确提示并中止,而不是中途失败却仍显示「完成」。 - Paths come from the environment (v1.5.0). Program Files, the Windows directory and the Public desktop are resolved from
%ProgramFiles%/%SystemRoot%/%PUBLIC%, so the tool also works when Windows is not installed onC:. / 路径取自环境变量(v1.5.0):Program Files、Windows 目录、公共桌面均从%ProgramFiles%/%SystemRoot%/%PUBLIC%解析,因此 Windows 不在 C 盘时同样可用。 - Pure PowerShell, no external dependencies (only the built-in PowerShell / .NET). / 所有脚本均为纯 PowerShell,无外部依赖(仅需系统自带的 PowerShell / .NET)。
- Download the repository (or the ZIP from Releases) and unzip the whole folder. / 下载仓库(或 Release 附件的 ZIP),解压整个文件夹。
- Double-click
Start-GUI.bat(English name) or the Chinese launcher①运行C盘瘦身.bat— it requests Administrator automatically; click Yes. / 双击Start-GUI.bat(英文名)或中文启动器①运行C盘瘦身.bat(会自动请求管理员权限,点「是」即可)。 - Follow the UI. The target drive defaults to
D:and can be changed in the UI or on the command line. / 按界面提示操作;目标盘默认 D:(可在界面/命令行改为其他盘符)。
Want it fully automatic? Double-click
OneClick-Auto.bat(②一键全自动.bat). Setting up a brand-new PC? Double-clickFresh-Setup.bat(④新电脑初始化.bat).想什么都不用点、全自动跑完所有步骤?双击
OneClick-Auto.bat(②一键全自动.bat)。 新电脑首次初始化?双击Fresh-Setup.bat(④新电脑初始化.bat)。
| English launcher / 英文名 | Chinese twin / 中文名 | What it does / 作用 |
|---|---|---|
Start-GUI.bat |
①运行C盘瘦身.bat |
Graphical interface — recommended for first use / 图形界面,点击按钮(推荐,第一次用这个) |
OneClick-Auto.bat |
②一键全自动.bat |
Runs every step unattended / 全自动跑完所有步骤(无界面) |
CLI-Menu.bat |
③命令行菜单.bat |
Interactive text menu (Enter = run all) / 交互式文本菜单(回车 = 全部) |
Fresh-Setup.bat |
④新电脑初始化.bat |
New-PC baseline / 新机基线 |
Both sets do exactly the same thing — the Chinese names are kept so existing desktop shortcuts keep working; the English names are there for an international audience. 两套完全等价:保留中文名是为了不让你已有的桌面快捷方式失联,英文名面向国际用户。
diag / store-move / win32-move / appdata-reloc / cache-clean / longterm / userfolders-move / debloat
Defaults to D:. To use E: run CLI-Menu.bat E (or append the drive letter to any .bat).
默认 D:。要用 E: 则:CLI-Menu.bat E(或任意 .bat 加盘符参数)。
1) Diagnostic 诊断扫描 scan C: usage, Store apps, PF, AppData
6) Cache cleanup 缓存清理 drain npm/pnpm/uv/pip caches (folders kept)
T) TEMP + leftovers TEMP清理+冗余检查 drain every TEMP on C:/D:, check leftovers
N) New-install scan 新装接管 auto-redirect freshly installed programs
8) Long-term protect 长期防护 Storage Sense, TEMP redirect, scheduled tasks
R) Routine (6+T+N+8) 例行维护 one-click regular cleanup
--- One-time migration (first run only) / 一次性迁移(仅首次) ---
2) Debloat Microsoft 精简内置应用 remove least-used built-in apps (whitelist)
3) Store app migration Store应用迁移 move removable Store apps to D:\
4) Win32 relocation 大程序迁移 move big Program Files apps to D:\ (junction)
5) AppData redirect AppData重定向 lossless link big AppData folders to D:\
7) Move user folders 用户文件夹迁移 Desktop/Documents/Downloads/... to D:\
A) Run ALL migration 全部迁移 steps 2-7 in order (one-time)
F) Fresh-setup 新机基线 new PC baseline (folders + Store + longterm)
Q) Quit 退出
- Create
D:\Program Files,D:\WindowsApps,D:\Users - Make
D:the default install drive for Store apps - Move user folders to
D: - Point package managers at
D:(scoop / chocolatey / winget) - Apply long-term protection
Honest note / 诚实说明:Windows has no safe global "install everything to D:" switch — classic
.exe/.msiinstallers still ask you to pickD:\Program Filesin their wizard. Windows 没有安全的「全局装到 D」开关,经典.exe/.msi安装器仍需你在向导里选D:\Program Files。
longterm.ps1 registers three tasks (re-running it updates them in place, and removes the
pre-v1.4.0 CCleanGuard-* names):
longterm.ps1 会注册三个计划任务(重跑即原地更新,并自动移除 v1.4.0 之前的 CCleanGuard-* 旧任务名):
| Task / 任务名 | Schedule / 频率 | Runs / 执行 |
|---|---|---|
C-Slim-Maintain |
Weekly, Sun 3am / 每周日 3:00 | maintain.ps1 — every TEMP (recycle bin only with -EmptyRecycleBin) / 全部 TEMP(回收站仅加 -EmptyRecycleBin 才清) |
C-Slim-Monitor |
Daily, 9am / 每天 9:00 | space-monitor.ps1 — triggers cleanup when either drive drops below 20 GB / 任一盘低于 20GB 即触发清理 |
C-Slim-NewInstall |
Daily, 4am / 每天 4:00 | new-install-scan.ps1 — auto-relocate freshly installed programs / 自动接管新装软件 |
After upgrading, re-run
longterm.ps1once (menu8) so the scheduled tasks pick up the new command lines and the safe cleanup. / 升级后请重跑一次longterm.ps1(菜单8),让计划任务用上新的命令行与安全清理逻辑。
Every step writes a timestamped .log into the log\ subfolder next to the scripts. Routine
cleanup logs are auto-trimmed after 7 days; one-time migration / new-PC logs are kept forever
so they can be reviewed later.
每个步骤都会在脚本所在目录的 log\ 子文件夹里生成带时间戳的 .log:日常清理日志每次运行自动清理 7 天前的旧日志;一次性迁移/新机日志永久保留,便于复盘。
common.ps1 Shared helpers: prompts, safe-delete primitives, paths / 共享助手:提示、安全删除原语、路径
C-Slim.ps1 CLI entry point / CLI 主入口
C-Slim-GUI.ps1 Graphical interface / 图形界面
diag.ps1 Read-only diagnostics / 只读诊断扫描
win32-move.ps1 Relocate large programs (junction) / 迁移大型程序
appdata-reloc.ps1 Redirect AppData folders / 重定向 AppData
userfolders-move.ps1 Move user shell folders / 迁移用户文件夹
store-move.ps1 Move Store apps / 迁移 Store 应用
debloat.ps1 Debloat built-in apps (whitelist) / 精简预装应用
cache-clean.ps1 Drain package-manager caches / 抽干包管理器缓存
maintain.ps1 Routine: every TEMP (recycle bin only with -EmptyRecycleBin) / 日常维护:全部 TEMP(回收站仅加 -EmptyRecycleBin 才清)
space-monitor.ps1 Dual-drive space guard / 双盘空间巡检
longterm.ps1 Long-term protection + scheduled tasks / 长效保护与计划任务
fresh-setup.ps1 New-PC baseline / 新机基线
rehome-legacy.ps1 Fold a legacy data root into D:\Users / 旧数据根安全整合进 D:\Users
new-install-scan.ps1 Auto-relocate new installs / 新装软件自动接管
verify-health.ps1 Read-only health check / 只读体检
*.bat Launchers (right-click → Run as administrator) / 启动器(右键管理员运行)
- Bilingual (
EN / 中文): script headers (# CN:line), CLI menu, GUI buttons and labels, confirmation dialogs, warnings, and final summaries. 双语:脚本头部(# CN:行)、CLI 菜单、GUI 按钮与标签、确认对话框、警告、完成总结。 - Chinese only: per-item progress lines. Doubling every line would make logs unreadable. 仅中文:逐条过程日志。每行都双语会让日志难以阅读。
- All
.ps1files are UTF-8 with BOM — without it, Chinese Windows reads them as GBK and the parser fails. / 所有.ps1均为带 BOM 的 UTF-8:否则中文 Windows 会按 GBK 读取导致解析失败。
MIT — see LICENSE. Use it, fork it, ship it; just keep the copyright notice. MIT — 详见 LICENSE。可自由使用、Fork 与分发,保留版权声明即可。