Introduction
Temporary files are files created by programs to store data during operation: caches, intermediate data, update files, etc. Over time, they can accumulate and take up significant space on the system drive (sometimes several gigabytes). Regularly cleaning temporary files helps:
- Free up disk space, especially if it's nearly full.
- Improve system performance (less fragmentation, faster utility operation).
- Eliminate potential program conflicts caused by outdated temporary data.
In this guide, you'll learn how to clean temporary files in Windows both manually and using built-in tools. The instructions apply to Windows 7, 8.1, 10, and 11.
Requirements
Before you begin, ensure that:
- You have administrator access to the computer (required to delete system temporary files).
- Your operating system is Windows 7 or newer.
- You have closed all running applications (especially browsers, office suites, graphics editors) to avoid file locking.
Step 1: Preparation: Close Programs
Close all open applications that might actively use temporary files. This will prevent errors like "File is in use by another process" when attempting deletion. It's particularly important to close:
- Web browsers (Chrome, Firefox, Edge, etc.) — they actively write cache.
- Office suites (Word, Excel) — may hold open temporary files.
- Graphics editors (Photoshop, GIMP) and video editors.
- Games running in the background.
If you're unsure which programs are running, open Task Manager (Ctrl+Shift+Esc) and end unnecessary processes (carefully—do not close system processes!).
Step 2: Clean User Temporary Files
User temporary files are stored in the folder specified by the %TEMP% environment variable. Typically, this is C:\Users\<Username>\AppData\Local\Temp.
- Press Win+R, type
%temp%, and press Enter. - In the opened folder, select all files: Ctrl+A.
- Delete them: press Delete or right-click → Delete. For permanent deletion without the Recycle Bin, use Shift+Delete.
- If the system reports that some files cannot be deleted (because they are in use), click Skip — these files will be deleted during the next reboot or after closing the program.
⚠️ Important: Do not delete the
Tempfolder itself, only its contents. Also, do not delete files that were modified in the last few minutes—they may be needed by active programs.
Step 3: Clean System Temporary Files
System temporary files are stored in the C:\Windows\Temp folder. They are created by Windows itself and system services.
- Press Win+R, type
temp, and press Enter. - Similarly, select all files (Ctrl+A) and delete them.
- If administrator privileges are requested, click Continue.
- Skip files that cannot be deleted.
💡 Tip: If you cannot delete some files due to insufficient permissions, open the folder as an administrator: press Shift + right-click on the
Tempfolder → Open command window here (as administrator) and run the commanddel /f /q *.*.
Step 4: Use the 'Disk Cleanup' Utility
The Disk Cleanup utility (cleanmgr) removes not only temporary files but also other service data (update cache, temporary internet files, etc.).
- Press Win+R, type
cleanmgr, and press Enter. - Select the system drive (usually
C:) and click OK. - The utility will analyze disk space (this may take several minutes).
- In the list of categories, check:
- Temporary files (main category).
- Windows Update Cleanup (can take up a lot of space).
- Browser cache (if installed).
- Other categories as desired (e.g., Recycle Bin, Temporary Internet Files).
- Click OK → Delete Files.
- Wait for completion.
⚠️ For Windows 7/8.1: The utility may not show all categories. To add "Temporary Files," click Clean up system files (requires administrator privileges) and select the desired items.
Step 5: Configure Automatic Cleanup (Storage Sense)
Windows 10 and 11 include the built-in Storage Sense feature, which automatically deletes temporary files on a schedule. For Windows 7 and 8.1, this feature is not available, but alternatives exist.
For Windows 10/11:
- Open Windows Settings: Win+I → System → Storage.
- Enable Storage Sense (toggle switch).
- Click Configure Storage Sense or Automatically free up space.
- Configure:
- Run Storage Sense: daily, weekly, monthly, or when low on space.
- Delete temporary files: check "Temporary files from apps," "Temporary files," etc.
- Clear the Downloads folder (if desired) and Recycle Bin.
- Click OK.
For Windows 7/8.1:
- Create a task in Task Scheduler:
- Open Task Scheduler (Win+R →
taskschd.msc). - Create a basic task (in the right pane).
- Trigger: on a schedule (e.g., monthly).
- Action: run
cleanmgr.exewith arguments/sageset:1(setup) and/sagerun:1(run). First run/sageset:1, select categories, then in the task specify/sagerun:1.
- Open Task Scheduler (Win+R →
- Alternatively, use third-party utilities (e.g., CCleaner), but with caution.
Verify the Result
After cleaning, check how much space was freed:
- Open This PC and view free space on the system drive (usually
C:). - Compare with the previous value (you could have taken a screenshot before cleaning).
- Run Disk Cleanup (
cleanmgr) again—if the "Temporary Files" category shows 0 bytes, the cleanup was successful. - Check performance: the computer should run slightly faster, especially if the disk was over 90% full.
Potential Issues
1. Some files won't delete
Cause: Files are locked by active processes.
Solution:
- Close all programs and try deletion again.
- Reboot the computer and perform cleanup immediately after startup (before opening programs).
- Use the Unlocker or Process Explorer (from Microsoft) to force-unlock files, but be careful.
2. Not enough space to perform cleanup
Cause: The disk has very little free space, and utilities cannot create temporary files to operate.
Solution:
- Manually delete a few large files (e.g., from
Downloads,Videos,Musicfolders). - Move data to an external drive.
- Use Disk Management (
diskmgmt.msc) to shrink the volume or delete system restore points.
3. Storage Sense doesn't work (Windows 10/11)
Cause: The feature is disabled or conflicts with other software.
Solution:
- Ensure Storage Sense is enabled in Settings.
- Check if antivirus or system optimizer is blocking it.
- Restart the Storage Sense service: open Services (
services.msc), find "Storage Sense," and restart it.
4. Space is quickly reoccupied after cleanup
Cause: Programs (especially browsers) rapidly create new temporary files.
Solution:
- Configure Storage Sense for more frequent automatic cleanup.
- Limit browser cache in their settings (e.g., in Chrome: Settings → Privacy and security → Clear browsing data → "Cached images and files").
- Perform manual cleanup regularly (once a month).
5. Access error to C:\Windows\Temp folder
Cause: Insufficient administrator privileges.
Solution: Open File Explorer as an administrator (Shift + right-click on Explorer → "Run as administrator") and retry deletion. Or use an elevated Command Prompt:
del /f /s /q C:\Windows\Temp\*