Windows 11 stores temporary files in more than one location. The safest Command Prompt method is to delete the contents of a Temp folder while leaving the folder itself intact.
You can clean your current user’s Temp folder with del and rd, clean the system Temp folder from an elevated prompt, or use the Command Prompt version of Disk Cleanup.
Before you start: open Command Prompt as administrator
Administrator access is not normally required for your personal Temp folder. It may be required when cleaning %WINDIR%\Temp or files outside your user profile.
- Select the Search box on the Windows 11 taskbar.
- Type Command Prompt.
- Select Run as administrator.
- Select Yes when User Account Control asks for permission.
On current Windows 11 installations, Command Prompt may open inside Windows Terminal. That is still cmd.exe, so the commands below work normally.
#1 Best Overall
- 【Versatile Storage Expansion – For Gaming, Work & Everyday Use】 Running out of space on your PS5 or Xbox Series X/S? This external hard drive lets you store and play PS4 / Xbox One games directly, instantly freeing up your console’s internal storage for next‑gen titles. At the same time, it handles work file backups, media libraries, and cross‑device data transfers with ease. One drive, all your needs. *(Note: PS5 / Xbox Series X|S games cannot be run or stored directly from the external hard drive. However, by offloading your PS4 / Xbox One games, you can free up valuable space for newer titles.)*
- 【Patented Silicone Sleeve – Data Protection You Can Count On】 Worried about drops? We’ve got you covered. The patented built‑in silicone sleeve acts like a shock‑absorbing armor, cushioning your drive against bumps and falls. Whether it’s important work documents, precious family photos, or hard‑earned game saves, your data deserves this level of protection.
- 【Plug & Play, Compatible with Computers & Consoles】 No complicated setup—just plug in and go. Works seamlessly with Windows, Mac, and Linux computers, as well as PS4, PS5, Xbox One, and Xbox Series X/S. Process files at the office, back up data at home, or enjoy gaming in your downtime—one drive handles all your devices, simply and hassle‑free.
- 【USB 3.0 Ultra‑Fast Transfer – No More Waiting】 Tired of watching progress bars crawl? With USB 3.0 speeds up to 5Gbps, large files transfer in seconds. Whether you’re moving work documents, transferring hundreds of gigs of games, or backing up a year’s worth of photos, you get more done in less time.
- 【Sleek, Lightweight, and Ready to Go】 Weighing just 0.16 kg—lighter than a can of soda—this compact drive features a stylish mirror‑and‑frosted finish. Toss it in your bag and go, whether you’re heading to the office, visiting a friend for a gaming session, or giving a presentation on the road.
1. Find and inspect your Temp folder
Start by checking which temporary folder the current Command Prompt process is using:
echo %TEMP%
echo %TMP%
These variables commonly point to a path similar to:
C:\Users\YourName\AppData\Local\Temp
Do not assume that every Windows account uses the same Temp folder. Environment variables belong to the process and its user environment.
List the folder, including hidden and system files, before deleting anything:
dir /a “%TEMP%”
The /a switch includes hidden and system files in the listing.
2. Delete files from the current user’s Temp folder
Run this command:
del /f /s /q “%TEMP%\*”
| Part | Purpose |
|---|---|
| del | Deletes files. |
| /f | Forces deletion of read-only files. |
| /s | Processes matching files in the folder and its subfolders. |
| /q | Suppresses confirmation prompts. |
| “%TEMP%\*” | Targets the contents of Temp, not the Temp folder itself. |
Important: Command Prompt’s del command permanently deletes files. They do not go to the Recycle Bin through the normal deletion process.
3. Remove temporary subfolders
del removes files but does not remove the directory structure. To remove subfolders left inside Temp, run:
for /d %D in (“%TEMP%\*”) do @rd /s /q “%D”
The Tool Desk
Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →Here, rd is an alias for rmdir. The /s switch removes each matching directory tree, and /q avoids an extra confirmation prompt.
Rank #2
- 【Versatile Storage Expansion – For Gaming, Work & Everyday Use】 Running out of space on your PS5 or Xbox Series X/S? This external hard drive lets you store and play PS4 / Xbox One games directly, instantly freeing up your console’s internal storage for next‑gen titles. At the same time, it handles work file backups, media libraries, and cross‑device data transfers with ease. One drive, all your needs. *(Note: PS5 / Xbox Series X|S games cannot be run or stored directly from the external hard drive. However, by offloading your PS4 / Xbox One games, you can free up valuable space for newer titles.)*
- 【Patented Silicone Sleeve – Data Protection You Can Count On】 Worried about drops? We’ve got you covered. The patented built‑in silicone sleeve acts like a shock‑absorbing armor, cushioning your drive against bumps and falls. Whether it’s important work documents, precious family photos, or hard‑earned game saves, your data deserves this level of protection.
- 【Plug & Play, Compatible with Computers & Consoles】 No complicated setup—just plug in and go. Works seamlessly with Windows, Mac, and Linux computers, as well as PS4, PS5, Xbox One, and Xbox Series X/S. Process files at the office, back up data at home, or enjoy gaming in your downtime—one drive handles all your devices, simply and hassle‑free.
- 【USB 3.0 Ultra‑Fast Transfer – No More Waiting】 Tired of watching progress bars crawl? With USB 3.0 speeds up to 5Gbps, large files transfer in seconds. Whether you’re moving work documents, transferring hundreds of gigs of games, or backing up a year’s worth of photos, you get more done in less time.
- 【Sleek, Lightweight, and Ready to Go】 Weighing just 0.16 kg—lighter than a can of soda—this compact drive features a stylish mirror‑and‑frosted finish. Toss it in your bag and go, whether you’re heading to the office, visiting a friend for a gaming session, or giving a presentation on the road.
Do not run this while Command Prompt’s current directory is inside the Temp folder. Change to another directory first, for example:
cd /d “%USERPROFILE%”
for /d %D in (“%TEMP%\*”) do @rd /s /q “%D”
Using the command in a batch file
The syntax changes slightly in a .bat or .cmd file. Double the percent sign used for the for variable:
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
for /d %%D in (“%TEMP%\*”) do @rd /s /q “%%D”
Use %D when typing directly into Command Prompt and %%D inside a batch file.
Complete command sequence for the user Temp folder
This sequence displays the target, shows its contents, deletes files, and then removes subfolders:
echo %TEMP%
dir /a “%TEMP%”
del /f /s /q “%TEMP%\*”
for /d %D in (“%TEMP%\*”) do @rd /s /q “%D”
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsReview the output of the first two commands before running the deletion commands. The main Temp folder remains in place.
Clean the Windows system Temp folder
The system Temp folder is separate from your personal Temp folder. Its usual location is:
Rank #3
- 【Plug-and-Play Expandability】 With no software to install, just plug it in and the drive is ready to use in Windows(For Mac,first format the drive and select the ExFat format.
- 【Fast Data Transfers 】The external hard drives with the USB 3.0 cable to provide super fast transfer speed. The theoretical read speed is as high as 110MB/s-133MB/s, and the write speed is as high as 103MB/s.
- 【High capacity in a small enclosure 】The small, lightweight design offers up to 500GB capacity, offering ample space for storing large files, multimedia content, and backups with ease. Weighing only 0.35 Lbs, it's easy to carry "
- 【Wide Compatibility】Supports PS4 5/xbox one/Windows/Linux/Mac and other operating systems, ensuring seamless integration with game consoles,various laptops and desktops .
- Important Notes for PS/Xbox Gaming Devices: You can play last-gen games (PS4 / Xbox One) directly from an external hard drive. However, to play current-gen games (PS5 / Xbox Series X|S), you must copy them to the console's internal SSD first. The external drive is great for keeping your library on hand, but it can't run the new games.
C:\Windows\Temp
Verify the actual Windows directory and inspect the target:
echo %WINDIR%\Temp
dir /a “%WINDIR%\Temp”
From an elevated Command Prompt, delete its contents with:
Recommended Free Tools
del /f /s /q “%WINDIR%\Temp\*”
for /d %D in (“%WINDIR%\Temp\*”) do @rd /s /q “%D”
Windows and running applications may have some files open. Those files normally remain; do not terminate system processes just to complete the cleanup.
Use Disk Cleanup from Command Prompt
Windows 11 still includes Microsoft’s documented cleanmgr.exe tool. It provides categorized cleanup rather than deleting everything in a Temp directory.
Open Disk Cleanup
cleanmgr
To target a particular drive:
cleanmgr /d C:
Disk Cleanup can offer categories such as Temporary Files, Temporary Setup Files, Temporary Internet Files, and Recycle Bin contents. Review the categories before confirming.
Save a cleanup profile
To choose categories once and reuse them later:
cleanmgr /sageset:1
Select the categories in the Disk Cleanup Settings window. Then run the saved profile with:
cleanmgr /sagerun:1
The number identifies the profile. Microsoft documents values from 0 through 9999, so you can create separate profiles for different cleanup choices.
Graphical alternative: Storage settings
If you prefer Windows’ categorized cleanup interface, open:
Rank #4
- Ultra fast data transfers: the external hard drive works with USB 3.0 thickened copper cable to provide super fast transfer speeds. Theoretical read speed is as high as 110MB/s-133MB/s and write speed is as high as 103MB/s.
- Ultra-thin and quiet: the motherboard adopts a noise-free solution, giving you a quiet working environment. Lightweight and portable size designed to fit in your pocket for easy portability.
- Compatibility: compatible with PS4/xbox one/Windows/Linux/Mac/Android,Stable and fast downloading on game console no difference from fast transmission when using on PC.
- Plug and Play: no software to install, just plug it in and the drive is ready to use. The hard drive chip is wrapped with aluminum anti-interference layer to increase heat dissipation and protect data
- Package Contents: 1* portable hard drive, 1 *USB 3.0 cable, 1*USB to type C adapter,1 *user manual, shell packaging, three-year manufacturer's warranty and free technical support services
Start > Settings > System > Storage
Select Temporary files to review available categories. You can also open Storage Sense from the same area. Storage Sense can remove unnecessary temporary files and Recycle Bin contents on the system drive, normally C:. For another drive, Microsoft’s path is Advanced storage settings > Storage used on other drives.
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Clear out junk files and repair common Windows errorsFree Scan →What to do when cleanup fails
| Message or symptom | Likely cause and fix |
|---|---|
| The process cannot access the file because it is being used by another process | Close applications, installers, and other tools that may be using the file. Try again after restarting Windows if necessary. Locked files can safely remain. |
| Access is denied | Reopen Command Prompt with Run as administrator, especially when cleaning %WINDIR%\Temp. Elevation still does not unlock files actively being used. |
| The directory is not empty | Use rd /s /q for a directory tree. Inspect hidden and system entries with dir /a. |
| Read-only files remain | del /f handles read-only attributes, but not locked, corrupted, or otherwise protected files. |
| Hidden or system files remain | First identify the specific file with dir /a. For a file you have verified is in Temp, its attributes can be changed with a command such as attrib -h -s “path\to\file”. Do not apply this blindly to unrelated system files. |
| The folder fills up again | This is normal. Windows and applications create temporary files while they run. Cleanup does not prevent new Temp files. |
Commands to avoid
A commonly repeated shortcut is:
rd /s /q %TEMP%
This targets the entire Temp directory tree. It is better to delete the contents with del and remove only the subfolders with the separate for /d command. That approach preserves the main Temp folder and reduces the chance of disrupting software that expects the directory to exist.
Clearing %TEMP% does not remove every cache, Windows update file, or storage category. Use cleanmgr or Settings > System > Storage > Temporary files for broader cleanup categories.
Sources
- Microsoft Learn: del command
- Microsoft Learn: rmdir command
- Microsoft Learn: cleanmgr command
- Microsoft Learn: dir command
- Microsoft Support: Storage settings in Windows
FAQ
Is it safe to delete everything in the Windows 11 Temp folder?
Deleting unused contents of your user Temp folder is generally safe, but files currently used by Windows or an application may fail to delete. Close running programs first and leave locked files in place. Do not delete the Temp folder itself.
Do CMD-deleted temporary files go to the Recycle Bin?
No. The del command permanently deletes files rather than moving them to the Recycle Bin.
Why does the Temp folder come back after I delete it?
Windows and applications need temporary storage and recreate files and folders as they run. The main Temp folder should remain available.
Do I need administrator rights to clear Temp files?
Usually not for %TEMP%, which belongs to the current user. Administrator access may be required for %WINDIR%\Temp or files belonging to another account.
Does deleting %TEMP% clean all temporary files in Windows 11?
No. Windows uses multiple temporary-file and cache locations. Run cleanmgr or review Settings > System > Storage > Temporary files for broader categories.
The Bottom Line
For a controlled Command Prompt cleanup, verify the target with echo %TEMP% and dir /a, then run del /f /s /q “%TEMP%\*” followed by the for /d command to remove subfolders. Use an elevated prompt only when cleaning the system Temp folder, and expect locked files to remain.
Free tools Windows power users keep installed
One-click scans. No signup required.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

