
2025/03/22
Lightweight Command-Line C Drive Cleanup
A set of light command-line actions for remote/batch cleanup, with admin reminders.
For remote maintenance or batch pushes, command line is easiest—script it and run in one go.
Common commands:
del /s /q %TEMP%\*
del /s /q C:\Windows\Temp\*
cleanmgr /sageset:1 & cleanmgr /sagerun:1
dism /online /cleanup-image /startcomponentcleanup- Pair
delwithforfiles /D -7to filter by date and avoid deleting today’s files. cleanmgr: configure with /sageset, then automate with /sagerun; add to Task Scheduler.dismslims WinSxS; run as admin and expect longer runtime.- Send logs to shared storage to trace batch failures.
- If AV is present, allowlist the script path to avoid blocks.
Package into .bat or PowerShell with exit-code checks so remote machines clean reliably.
PowerShell version
Get-ChildItem $env:TEMP -Recurse | Remove-Item -Force
Get-ChildItem C:\Windows\Temp -Recurse | Remove-Item -Force- Pair with
Start-Transcriptto log for replay. - Add to Task Scheduler for overnight runs—clean by morning.
Further reading
More Posts

MaintenanceWindows
Portable C Drive Cleanup for Laptops
Use portable tools, avoid power-sensitive tasks, and watch battery life after cleanup.

MaintenanceWindows
Win10 C Drive Junk Cleanup Tutorial
Win10 deletable paths, pairing Disk Cleanup with tools, and safe update cache handling.

MaintenanceWindows
Fixing C Drive When the Bar Turns Red
Quickly spot large files and caches, clear Windows update packages, and inspect download/temp folders when the C drive goes red.
Newsletter
Join the community
Subscribe to our newsletter for the latest news and updates