To delete junk files in Windows 10 with Command Prompt, open Command Prompt as administrator and run del /q /f /s %TEMP%\* to empty your temporary folder. For a fuller cleanup, run cleanmgr /sageset:1 once to choose what to clean, then cleanmgr /sagerun:1 whenever you want to clean it. Files in use are skipped, which is normal.
These commands delete files without sending them to the Recycle Bin, so type them exactly as shown and don’t point them at other folders.
Note: Windows 10 reached end of support on October 14, 2025. Consumer Extended Security Updates (ESU) now run until October 12, 2027. The same commands work on Windows 11.
Quick Answer
Open Command Prompt as administrator, type del /q /f /s %TEMP%\*, and press Enter.
Step 1: Open Command Prompt as Administrator
- Select Start and type cmd.
- Right-click Command Prompt and choose Run as administrator.
- Select Yes on the User Account Control prompt.
Step 2: Delete Your Temp Files
- Close other apps so fewer files are in use.
- Type
del /q /f /s %TEMP%\*and press Enter. - Windows lists each deleted file. Messages saying a file is in use can be ignored.
- To also remove empty subfolders, run
for /d %i in ("%TEMP%\*") do rd /s /q "%i".

What the switches mean
| Switch | Meaning |
|---|---|
| /q | Quiet: don’t ask to confirm |
| /f | Force-delete read-only files |
| /s | Include subfolders |
Step 3: Clean the Windows Temp Folder
Run del /q /f /s C:\Windows\Temp\* in the same administrator window. Some files will be in use and skipped.
Step 4: Run Disk Cleanup From the Command Line
- Type
cleanmgr /sageset:1and press Enter. - Check the categories you want, such as Temporary files, Windows Update Cleanup, and Delivery Optimization Files, and select OK.
- Run
cleanmgr /sagerun:1to clean them now and any time later.
Step 5: Remove Old Update Components (Optional)
Run DISM /Online /Cleanup-Image /StartComponentCleanup to remove superseded Windows update files. It can take several minutes. Afterward, you can’t uninstall older updates.
What Not to Delete
- Don’t run del on the
C:\Windowsfolder itself,System32, or Program Files. Only the Temp folders are safe to empty. - Don’t delete the SoftwareDistribution folder while updates are installing. If you need to reset it, follow our guide to clearing the Windows Update cache.
- Don’t delete Prefetch files to “speed up” the PC; Windows rebuilds them and startup may briefly slow down.
Prefer a guided approach for update files? Our walkthrough on removing old Windows updates explains what each option deletes.
Troubleshooting
- “Access is denied”: You’re not in an administrator window, or the file is in use. Restart and try again.
- “The system cannot find the path specified”: Check for typos, especially the backslash before the asterisk.
- Want a point-and-click method? See how to clear temp files from Settings; the steps are nearly the same on Windows 10.
New to the command line? Here’s how to open a folder in Command Prompt.
Frequently Asked Questions
Is it safe to delete everything in %TEMP%?
Yes. Files that apps still need are in use and won’t be deleted.
Can I automate this?
Save the commands in a .bat file and run it with Task Scheduler, or turn on Storage Sense in Settings.
Summary
- Open Command Prompt as administrator.
- Run
del /q /f /s %TEMP%\*. - Use
cleanmgr /sageset:1and/sagerun:1for a full cleanup. - Stay away from system folders.

Kermit Matthews is a freelance writer based in Philadelphia, Pennsylvania with more than a decade of experience writing technology guides. He has a Bachelor’s and Master’s degree in Computer Science and has spent much of his professional career in IT management.
He specializes in writing content about iPhones, Android devices, Microsoft Office, and many other popular applications and devices.