Cleaning Temp Files Without Touching the Mouse
I've spent more hours than I care to admit watching progress bars crawl across the screen while Windows chews through "Cleaning up temporary files..." like it's trying to find something specific. There's a better way. Command prompt does this faster, it doesn't ask stupid questions, and it doesn't lie to you about how much space you'll free up. Open a command prompt as administrator. Yes, admin matters here because some temp folders belong to the system itself, and a normal session will skip those and throw errors that look scarier than they are. Right-click the Start button, pick "Terminal (Admin)" or "Windows PowerShell (Admin)" depending on your build, or just search cmd, right-click, and run as administrator. Here's what actually works in practice:
del /q/f/s "%TEMP%\*" - This clears your user temp folder. The /q suppresses confirmation prompts, /f forces deletion of read-only files, /s goes through subdirectories. Your applications will complain when they next try to use files they just lost, but that's usually harmless. Most programs regenerate what they need. del /q/f/s "C:\Windows\Temp\*" - System temp folder. Same logic. Sometimes files here are locked by running processes and the command will quietly skip those. That's normal. Don't panic and don't try to delete them one by one. cleanmgr /sagerun:1 - This opens the Disk Cleanup dialog in automated mode. You set up a cleanup profile once with the checkboxes you want, assign it number 1, and then the /sagerun flag executes it without the dialog. You can set up multiple profiles for different cleanup levels. Useful if you want to target specific things like Windows Update cleanup or previous Windows installations without sifting through menus.
compact /U /S /I %SYSTEMDRIVE%\*.tmp - This one's less common but worth knowing. It compacts instead of deletes, which on NTFS drives means marking the space as available without necessarily zeroing it out. Slower than straight deletion but sometimes gentler on the drive if you're working with older hardware. I learned about the admin requirement the hard way. Back when I was still figuring this out, I ran the temp deletion commands from a standard prompt and got errors on about forty percent of the files. I assumed the files were corrupted or something. They weren't. I just didn't have permission. Twenty minutes of googling later, I found the answer. It's embarrassing how long it took me to connect "permission denied" with "run as admin." Here's something most guides won't tell you: the /q flag doesn't just suppress prompts, it also skips files that are currently open by other processes. Which is good, because trying to force-delete a file that's in use will either fail or crash the program using it. The command appears to complete successfully even though some files remain. Check the return code if you're scripting this. A zero means everything went through. Anything else means something blocked a deletion.
Get the Full Details

Another thing people miss: del /q/f/s with a wildcard only deletes files. If your temp folders have subdirectories with stuff inside that somehow wasn't caught by the /s flag, those directories persist. Use rmdir /s /q "C:\Windows\Temp\*" if you want to nuke empty leftover folders too. Or better yet, combine both approaches in a single batch file so you don't have to remember the sequence. One edge case that caught me off guard: Windows 10 and 11 can redirect your user temp folder to a different location using environment variables or registry settings. If %TEMP% points somewhere unexpected, you're cleaning the wrong folder. Check what echo %TEMP% returns before you run anything destructive. I once ran a cleanup script that emptied a completely different partition's temp directory because the environment variable had been set wrong during a software installation years ago. Took me a while to figure out why my work files were missing temporarily. There are limitations. This won't touch browser caches unless you point it there specifically. Chrome and Edge store their data elsewhere. You'd need del /q/f/s "%LOCALAPPDATA%\Google\Chrome\User Data\Default\Cache\*" and similar paths for other browsers. Firefox uses a different structure entirely under %LOCALAPPDATA%\Mozilla\Firefox\Profiles. And Windows Store apps? Their temp data lives under %LOCALAPPDATA%\Packages and the structure is fragmented across hundreds of subfolders.
Also, deleting temp files rarely makes a dramatic difference unless they've accumulated for months. On a typical home machine that gets used daily, you're looking at maybe two hundred megabytes to a couple gigabytes depending on what software you run. On a machine that runs heavy video editing or development work, sure, you might free tens of gigabytes. Don't expect a slow PC to suddenly become fast because you deleted some temp files. That's a myth that keeps showing up in articles that haven't been updated since 2012. If you want to automate this, stick it in a batch file with date stamps for logging. Something like: echo %date% %time% Starting temp cleanup >> C:\logs\temp_cleanup.log> C:\logs\temp_cleanup.log 2>&1> C:\logs\temp_cleanup.log 2>&1
Schedule it with Task Scheduler if you want it to run weekly without thinking about it. Set it to run with highest privileges and you don't need to remember to right-click and elevate every time. One setup, done forever. The other option is just opening the Disk Cleanup tool manually and letting it do its thing. It's slower and more confusing for most people, but it has the advantage of not requiring any knowledge of command syntax. Choose the tool that matches how often you actually plan to use it.
