Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Windows System Cleaner and Optimizer 🧹

CI Version License PowerShell Platform

A registry-driven Windows cleanup engine. Every operation is one declarative task; a small engine resolves what to run, reclaims disk space, and deletes through PowerShell's ShouldProcess — so -WhatIf is real, not a parallel code path.

It cleans 106 targets across browsers, developer tools, apps, games, system caches, every local disk, logs, Windows Update, and driver leftovers — all from one declarative registry with a real dry-run mode and a hard safety guard. A companion optimization engine applies 77 reversible system tweaks, a troubleshooting engine scans for 43 common problems and repairs them, and a single menu ties everything together.

A free, open-source Windows 10 and Windows 11 cleaner, debloater, and optimizer, written in PowerShell — reclaim disk space, remove bloatware, harden privacy and telemetry, tune performance, and diagnose common system problems, with a real dry-run and a System Restore safety net. Works on desktops, laptops, and Windows Server, and runs unattended for fleets.

Contents

One command — the desktop app

Open PowerShell (Win + X → Terminal / Windows PowerShell) and paste one line:

irm https://github.com/denfry/WindowsCleaner/releases/latest/download/install.ps1 | iex

That's it — no git, no zip, no admin prompt to install. The installer:

  1. reads the latest release's SHA256SUMS.txt, downloads the zip over HTTPS and refuses to install if the SHA256 does not match;
  2. puts the app in %LOCALAPPDATA%\WinSenior\app and adds Windows Senior to the Start menu and the desktop;
  3. starts the app, which asks for Administrator once (UAC).

Run the same line again to update. Options (the long form accepts parameters):

$i = [scriptblock]::Create((irm https://github.com/denfry/WindowsCleaner/releases/latest/download/install.ps1))
& $i -NoLaunch        # install / update only
& $i -Console         # open the arrow-key console menu instead of the app
& $i -NoShortcut      # no Start menu / desktop shortcuts
& $i -Uninstall       # remove the app and its shortcuts

Prefer to read before running? Download install.ps1 from the latest release — it is ~200 readable lines. Or work from a clone: the window is WPF, which ships with every Windows 10/11, so nothing else is needed.

git clone https://github.com/denfry/WindowsCleaner
cd WindowsCleaner
.\WinSenior.cmd          # or double-click it in Explorer

WinSenior.cmd removes the Mark-of-the-Web from the scripts (zip downloads), asks for Administrator once (UAC) and opens Windows Senior without a console window. .\WinSenior.ps1 -Gui does the same from PowerShell; .\WinSenior.cmd console opens the arrow-key menu instead.

The app has eight pages:

  • Disk cleanup — every task with its category and risk badge. Scan runs the real -WhatIf dry run and fills a "Would free" column per task; Clean now runs the checked tasks. Options: current user only, restore point, delete locked files at reboot, close running browsers, skip SFC/DISM, Conservative, minimum file age, which disks. Dangerous tasks are never pre-checked, and Clean now shows a confirmation with the estimate first. A filter box, sortable columns and tooltips with each task's paths on every list.
  • Optimize — all tweaks with their live applied / not applied state; preview or apply, restore point first, every applied tweak is backed up.
  • Troubleshoot — read-only scan with OK / Warn / Fail per check and the detail text; tick the problems to repair and press Fix selected, or auto-fix everything.
  • Startup apps — everything that starts with Windows (Run keys, Startup folders); untick to disable it exactly the way Task Manager does — the entry is kept, so ticking it again restores it.
  • History — every run's report (app and scheduled), all-time total freed, HTML export.
  • Undo & restore — list of optimization backup manifests (undo newest or a chosen one), create a System Restore point, open System Restore, open log folders.
  • Schedule — install/remove the recurring Task Scheduler jobs and see their next run.
  • About — versions, counts, paths.

Engine output streams into the log panel at the bottom (resizable, saveable, cancellable). The app never re-implements deletion: it launches the same engine scripts with parameters, so -WhatIf, the safety guard, restore points and undo are exactly the ones documented below. Selections and options persist in %ProgramData%\WinSenior\gui-settings.json.

The console menu

WinSenior.ps1 is the console entry point. Run it (it self-elevates) and an interactive menu opens with detailed screens for cleanup, optimization, troubleshooting, undo, a restore point and a task/tweak/check listing. It drives all three engines, so every action keeps real -WhatIf, the safety guard and per-tweak undo.

The menu is arrow-key driven: ↑/↓ move the highlight, Enter selects, Space toggles a task/tweak on the detailed screens, and Esc goes back. Add -Plain for terminals that can't render box-drawing characters (ASCII + - | borders instead).

.\WinSenior.ps1
.\WinSenior.ps1 -Plain   # ASCII-only borders

Highlights

  • One source of truth. Every cleanup target is a single entry in a task registry (-ListTasks prints it). Adding a target is one line; nothing else to wire up.
  • Real -WhatIf / -DryRun. Implemented through SupportsShouldProcess. Preview shows exactly what would be removed and reports honest would-free totals.
  • Real restore point. The SystemRestore WMI class actually creates a System Restore point under both Windows PowerShell 5.1 and PowerShell 7 (the 24-hour throttle is lifted for that one checkpoint and then put back) — non-interactive, safe for automation.
  • Links are never followed. A junction or symlink inside a cleaned folder is removed as a link; its target is never enumerated, counted or deleted.
  • Honest accounting. Reclaimed bytes are summed from items that were actually removed, not estimated and not counted from log lines. Partially-deleted folders count only what actually went away.
  • Locked files don't win. -DeferLocked queues anything in use for deletion at the next reboot through MoveFileEx(MOVEFILE_DELAY_UNTIL_REBOOT) — the same mechanism Windows Installer uses — instead of reporting an error. Age-filtered runs also prune the empty folder skeletons they leave behind.
  • A safety guard that can't be argued with. Test-SafeToDelete refuses to operate on drive roots, %WINDIR%, %USERPROFILE%, C:\Users, System32, or any path shallower than two levels — defends against a bad registry entry or an unexpanded variable.
  • Risk tiers. Safe / Moderate / Aggressive run by default; irreversible operations live in a Dangerous tier behind -IncludeDangerous.
  • ~15 parameters with short aliases, plus per-user (<USER>) and per-disk (<DRIVE>) path expansion.

Quick start

# Preview everything (no changes, real ShouldProcess)
.\Cleanup-Windows-Senior.ps1 -WhatIf

# Default aggressive cleanup, all users, with a real restore point first
.\Cleanup-Windows-Senior.ps1

# Just browser + developer-tool caches
.\Cleanup-Windows-Senior.ps1 -Category Browsers,DevTools

# Clean drive-level junk on specific local disks only
.\Cleanup-Windows-Senior.ps1 -Category Disks -Drives C,D

# Non-interactive for scheduled tasks / GPO / SCCM / Intune
.\Cleanup-Windows-Senior.ps1 -Unattended -NoRestorePoint -SkipOptimization

# Everything, including the irreversible tier, with a JSON report
.\Cleanup-Windows-Senior.ps1 -IncludeDangerous -ReportPath C:\Logs\clean.json

# One-time execution-policy bypass
powershell.exe -ExecutionPolicy Bypass -File .\Cleanup-Windows-Senior.ps1 -WhatIf

Run as Administrator. PowerShell 5.1+ (7+ recommended).

Parameters

Parameter Alias Effect
-Category <names> Limit to: Browsers, DevTools, Apps, Games, System, Disks, Logs, Updates, Optimization
-Include <ids> Force tasks on (ids from -ListTasks) — overrides category and risk cap
-Exclude <ids> Force tasks off — wins over everything
-IncludeDangerous Also run the irreversible tier (event logs, patch cache, Windows.old, old drivers)
-Conservative -SafeMode Cap at Safe + Moderate (skip Aggressive)
-CurrentUserOnly -cu Clean only the current profile (default: all users)
-Drives <letters> Local disks for drive-level cleanup, e.g. -Drives C,D (default: all local disks)
-WhatIf / -DryRun -dr Preview only, change nothing
-Unattended -Force, -f No prompts, no GUI — for automation
-NoRestorePoint -nrp Skip the restore point that is otherwise created first
-SkipOptimization -so Skip the slow SFC / DISM category
-MaxAgeDays <n> Only delete files older than n days
-DeferLocked -dl Locked/in-use files are scheduled for deletion at next reboot (MoveFileEx) instead of counted as errors
-LogPath <path> Text log (default %TEMP%\WindowsCleanup.log)
-ReportPath <path> Write a machine-readable JSON report
-ListTasks Print the task registry and exit
-Help Show usage

Risk tiers

Tier Runs by default? Examples
Safe yes browser caches, temp, thumbnails, dev/app/messenger caches, shader cache
Moderate yes recycle bin, crash dumps, font cache, WU download cache, DISM cleanup
Aggressive yes full SoftwareDistribution reset, prefetch, DISM /ResetBase, SFC
Dangerous only with -IncludeDangerous clear event logs, $PatchCache$, Windows.old, remove superseded drivers

-Conservative lowers the default ceiling to Moderate. -Include can force any single task on regardless of tier.

What gets cleaned

-ListTasks shows the live list. Categories:

  • Browsers — Chrome, Edge, Firefox, Opera, Yandex, Brave (all profiles, cache / code cache / GPU cache / service-worker cache).
  • DevTools — npm, pip, Yarn, NuGet http cache, Gradle, VS Code, JetBrains (caches/logs/temp), Visual Studio (ComponentModelCache, IntelliCode logs, telemetry), Nuitka, Go build cache, Dart/Flutter Pub cache, package-manager caches (winget, Chocolatey, Scoop, conda, cargo, Go module cache), Python tools (uv, poetry, pipx, pyenv), JVM wrappers (Maven/Gradle dists, sbt boot, kotlin daemon), .NET SDK temp & telemetry, Node toolchain (node-gyp, electron, bun, deno, Cypress), GitHub Desktop, Composer, Docker Desktop/WSL logs, pnpm store prune, docker system prune, and — off by default — ML model & browser-automation caches (HuggingFace, torch, Playwright, Puppeteer).
  • Apps — Windows app/UWP caches & temp state, Microsoft Teams (classic + new), Discord, Slack, Spotify, Telegram, WhatsApp, Zoom/Skype/Signal/Viber, a generic sweep of every Electron/Chromium app cache under AppData (Moderate), media players (VLC, WMP, Plex), Office document/web cache, OneDrive logs, Adobe media & Camera Raw cache, RDP bitmap cache, notification image cache, GPU vendor apps (NVIDIA App / GeForce Experience / AMD / Intel).
  • Games — launcher caches for Steam (shader/http/html), Epic, Battle.net, GOG; launcher logs & crash dumps (Steam, Epic, EA, Ubisoft, Riot, Xbox); engine caches (Unreal DDC, Unity, Godot); per-game shader caches on every disk (Aggressive).
  • System — user/Windows temp, service-account temps (LocalService / NetworkService / system profile), WinINet cache, thumbnail & icon cache, GPU/D3D shader cache, GPU driver installer leftovers (NVIDIA/AMD), WebCache, Delivery Optimization, BITS transfer queue, setup/upgrade/servicing logs (Panther, CBS, USO, WindowsUpdate.log), Offline Web Pages, Defender scan cache, PerfLogs, recent items, font cache, Windows logs, prefetch, DNS/ARP/ NetBIOS flush, silent Store cache reset, standby-memory purge (frees RAM), Windows Search index rebuild (Aggressive, off by default), and removal of superseded driver packages via pnputil (Dangerous; boot-critical and in-use drivers are never touched).
  • Logs additions — setup logs (Panther/setupapi), Defender scan history, diagnostics & telemetry caches (Diagnosis, ETL traces, SleepStudy, WDI), third-party app logs (Adobe, Autodesk, Corsair, Logitech, Razer, Intel, PowerToys, Terminal), installer leftovers (MSI temp, Squirrel/NSIS/Inno, Chrome/Edge updater downloads), empty-folder pruning in temp.
  • Updates additions (Dangerous, off by default) — disable hibernation & delete hiberfil.sys; delete all but the newest restore point / shadow copy.
  • Disks — drive-level cleanup across every local disk (C:, D:, E: …): per-drive Temp/tmp scratch folders and CHKDSK FOUND.* fragments. Recycle Bins on all drives are emptied by the Logs task. Restrict with -Drives C,D.
  • Logs — Windows Error Reporting, crash & memory dumps, old IIS logs (>14 days), Recycle Bin (all drives), event-log clearing (Dangerous).
  • Updates — Windows Update download cache (services stopped correctly), full SoftwareDistribution reset, patch cache (Dangerous), Windows.old & upgrade leftovers (Dangerous).
  • Optimization — DISM analyze / component cleanup / reset base, StartComponentCleanup task, SFC. Skipped entirely with -SkipOptimization.

Optimization

Optimize-Windows-Senior.ps1 is a second registry-driven engine that changes Windows settings instead of deleting files. Every tweak is one declarative entry; the engine snapshots prior state into a backup manifest before applying, so -Undo reverts an entire run. A real restore point is created first as a second safety net.

# Preview every tweak (no changes, real ShouldProcess)
.\Optimize-Windows-Senior.ps1 -WhatIf

# Apply the default privacy + performance set
.\Optimize-Windows-Senior.ps1 -Area Privacy,Performance

# Revert the most recent run
.\Optimize-Windows-Senior.ps1 -Undo

It covers 77 tweaks across four areas (including modern Windows 11 items — Recall/Copilot, tailored-ads and Spotlight, inking/typing & speech telemetry, and the taskbar/Start ad surfaces):

  • Performance — visual effects to best performance, zero menu/startup delay, High-Performance power plan, background apps off; (off by default) Ultimate plan, SysMain / Windows Search off, hibernation off.
  • Privacy — telemetry policy, advertising ID, consumer features, tips/spotlight, activity feed, Start web search and Cortana off; DiagTrack and dmwappushservice disabled; CEIP / telemetry scheduled tasks off.
  • Debloat — curated junk UWP removal (default on); Xbox and comms apps (off by default); Start-menu app suggestions off.
  • Network — GameDVR off, Game Mode on, network-throttling and multimedia reservation off; (off by default) Nagle off, NDU service off.

Debatable tweaks ship off by default — allowed by their tier but only applied when you toggle them on or -Include them. The engine never disables Defender real-time protection, never breaks Windows Update or the network stack wholesale, and never removes Edge or the Store. Removing UWP apps is partially irreversible; the manifest lists what to reinstall from the Store. -ListTweaks prints the live list, and -Undo reverts a run from its backup manifest (newest in %ProgramData%\WinSenior\backups, or a specific one with -BackupManifest).

Troubleshooting

Repair-Windows-Senior.ps1 is a third engine that diagnoses and repairs system health. Every check is one declarative entry: a read-only scan that returns OK / Warn / Fail, and an optional fix. The default flow is scan-then-choose — it scans (changing nothing), prints a health report, and lets you pick which detected issues to repair. Fixes run through ShouldProcess after a real restore point.

# Scan, show the report, then choose what to repair
.\Repair-Windows-Senior.ps1

# Diagnose only - never change anything
.\Repair-Windows-Senior.ps1 -ScanOnly

# Non-interactive: auto-apply every fixable issue, including heavy repairs
.\Repair-Windows-Senior.ps1 -FixAll -IncludeHeavy -Unattended

It runs 43 checks across eight categories — including security checks (firewall state, SMBv1, hosts-file and proxy/PAC hijack, Defender signatures), a System Restore safety-net check, print spooler / BITS / Store health, and predictive SSD wear & crash-history reporting, plus the originals: system image health (DISM), physical disk SMART health, low free space, volumes flagged for chkdsk, pending reboot, Windows Update components, internet & DNS, devices with driver errors, stopped critical services, Microsoft Defender health, WMI repository consistency, time synchronization, and recent critical/error events.

Heavy repairs (SFC, DISM RestoreHealth, Windows Update reset, network stack reset) are included but only run when you select them, or pass -FixAll -IncludeHeavy. Repairs only ever improve health — the engine enables Defender real-time protection, it never disables it. -ListChecks prints the live list.

Batch version

Cleanup-Windows-Senior.bat is the simple, dependency-free alternative. v6 brings it to parity with the engine's defaults and fixes the old bugs (each browser flag is now independent; real all-users iteration; Windows Update services stopped in the right order). The Dangerous tier is behind /IncludeDangerous; a real restore point is opt-in via /RestorePoint. Run Cleanup-Windows-Senior.bat /? for options. The PowerShell version is recommended — it has real -WhatIf, finer control, and the safety guard.

Cleanup-Windows-Senior.bat /DryRun
Cleanup-Windows-Senior.bat /CurrentUserOnly /nch /nff
Cleanup-Windows-Senior.bat /IncludeDangerous /RestorePoint

Automation (GPO / SCCM / Intune / Task Scheduler)

The -Unattended switch makes the run fully non-interactive (no prompts, no GUI) — the restore point is created programmatically with Checkpoint-Computer, so nothing blocks.

# Startup script / scheduled task
powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden `
  -File "C:\Scripts\Cleanup-Windows-Senior.ps1" -Unattended -SkipOptimization `
  -LogPath "C:\Logs\cleanup.log" -ReportPath "C:\Logs\cleanup.json"

Exit codes: 0 success, 2 administrator privileges required.

Recurring maintenance — one command

WinSenior.ps1 can register the recurring tasks for you (run as Administrator; it self-elevates):

.\WinSenior.ps1 -InstallSchedule   # register the maintenance tasks
.\WinSenior.ps1 -RemoveSchedule    # remove them

This creates two Task Scheduler jobs under \WinSenior\, running as SYSTEM:

Task When What
WinSenior Weekly Cleanup Weekly, Sun 03:00 unattended cleanup, no restore point, skips slow SFC/DISM
WinSenior Monthly Health Scan Monthly, 1st 03:30 read-only health scan (changes nothing)

Both write JSON reports to %ProgramData%\WinSenior\reports.

Report format

Every engine's -ReportPath writes the same envelope, so one parser reads them all:

{
  "Tool": "WinSenior", "Version": "6.3.0", "Engine": "Cleanup",
  "Host": "PC01", "Timestamp": "2026-06-24T03:00:11", "Mode": "Live",
  "RestorePoint": true, "DurationSec": 42.3,
  "Summary": { "TotalFreed": "1.20 GB", "TotalFiles": 8123, "TotalErrors": 2 },
  "Items": [ /* per-task / per-tweak / per-check detail */ ]
}

Summary holds the engine's counters (cleanup: freed bytes/files; optimize: applied/skipped; repair: fixed/reboot), and Items the per-unit breakdown.

Tests

The tests\*.Tests.ps1 files cover the pure logic of all three engines — selection, the safety guard, age filtering, formatting, -WhatIf accounting, a registry backup→apply→undo round-trip against a throwaway hive, and the troubleshooter's scan/fix dispatch. Requires Pester 5+:

Invoke-Pester -Path .\tests

Common issues (FAQ)

  • "running scripts is disabled" — powershell.exe -ExecutionPolicy Bypass -File ... or Set-ExecutionPolicy -Scope CurrentUser RemoteSigned.
  • Restore point not created — System Protection is off for the system drive. Enable it (Enable-ComputerRestore -Drive "C:\") or run with -NoRestorePoint.
  • Some items report errors — they were locked/in use (e.g. an open browser). Close the app and re-run; the engine counts these and continues.
  • Nothing happens — check you ran as Administrator (exit code 2 otherwise).

License

MIT © 2026 denfry. See LICENSE.

Author

denfry — github.com/denfry


🔒 Safety note

This tool deletes files and, in the Dangerous tier, makes irreversible changes. Always start with -WhatIf. Keep the default restore point on for important systems. The authors are not responsible for data loss from improper use — ensure you have backups.

About

Registry-driven Windows 10/11 cleaner, debloater & optimizer in PowerShell - real -WhatIf dry-run, System Restore safety, 63 cleanup tasks, 49 reversible tweaks, 25 health checks. Free and open source.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages