System Cleaner is a local Windows cleanup script that runs with administrator approval and deletes a scoped set of cache and temporary data. It is designed to be readable, auditable, conservative by default, and safer to inspect in Preview mode before any deletion takes place.
The project assumes:
- The operator can read the script before executing it.
- The operator can decide whether to approve Windows UAC elevation.
- Cleanup should remain local to the machine and avoid external communication.
- Destructive actions should be limited to known disposable paths.
This tool is not a sandbox, anti-malware product, secure-erase utility, or endpoint-control framework.
At runtime, the script follows a constrained flow:
- It resolves cleanup roots and protected exclusions.
- It requests elevation through the standard Windows UAC mechanism if required.
- It performs only the cleanup steps associated with the chosen mode.
- It prints live logs so the operator can review exactly what was attempted.
- It prints a final summary with disk-space impact and processed counts.
This is important because the tool runs elevated. The safest operating pattern is to review the script, run Preview, inspect the output, and only then run a destructive mode.
The script is intentionally scoped away from common user-content locations. By default, it does not target:
Downloads- Documents, Desktop, Pictures, Music, or Videos
- Arbitrary user-selected directories outside the approved cleanup roots
- Registry keys
- Startup entries
- Scheduled tasks
- Installed applications
- Credentials, password stores, or browser profiles as whole directories
Additional protected paths can be added with -ExtraExcludePath.
Administrator rights are required because some cleanup targets are system-owned. Elevated actions may include:
- Cleaning Windows temp directories
- Cleaning the Windows Update download cache
- Clearing the Recycle Bin in protected locations
- Stopping and restarting update-related services when needed
- Running
Dism.exeinAggressivemode - Clearing Windows event logs in
Aggressivemode
The script uses the standard UAC prompt for elevation. It does not implement a custom privilege-escalation mechanism.
The script is intended to remain local to the machine. It does not include built-in behavior for:
- Telemetry
- Cloud sync
- Web API calls
- Remote command execution
- Downloading payloads
Its core operations are limited to PowerShell file-system cmdlets, service-control cmdlets, Dism.exe, and wevtutil.exe.
Even conservative cleanup has real tradeoffs:
- Cache directories can contain useful offline data that will need to be rebuilt.
- Thumbnail, icon, and shader caches will be regenerated after cleanup.
- Some applications may lose transient state, thumbnails, or local cache indexes.
Aggressivemode clears event logs, which can reduce available troubleshooting history.- A third-party application that stores important data inside misleadingly named cache or temp folders under approved roots may still be affected.
These are operational risks, not hidden behavior. They are the reason Preview mode exists.
- Review
SystemCleaner.ps1. - Run
Previewmode first. - Check the printed actions against your environment.
- Add extra protected paths with
-ExtraExcludePathwhere needed. - Prefer
Standardmode unless you explicitly need the aggressive maintenance steps.
If you plan to distribute or publish the script:
- Re-check the default exclusion list.
- Re-check every hardcoded cleanup target.
- Confirm the stale-folder logic only covers acceptable roots and names.
- Confirm the aggressive mode description matches the actual behavior.
- Test
Previewmode on representative machines before recommending destructive execution.
If you discover a path that should not be cleaned by default, treat it as a scope bug. Tighten the exclusions or cleanup rules before further distribution.