How to Free Up Disk Space: 5 Hidden Windows Folders to Delete Now

Tech News May 3, 2026 10 min read

Overview

You bought a shiny new Windows PC with a 512 GB or even 1 TB solid-state drive. A year later, that drive is mysteriously half-full — and you haven’t installed anything dramatic. Where did all that space go?

Windows is quietly accumulating gigabytes of data in folders most users never know exist. These aren’t viruses or malware — they’re legitimate system folders that Windows uses for performance, updates, and troubleshooting. The problem is that Windows rarely cleans them up on its own, and over time they can balloon to tens of gigabytes. In some cases, users have discovered that these hidden folders are consuming 20–50 GB or more on their machine.

In this article, we’ll expose the main culprits: the User Temp folder, the System Temp folder, and the Windows Prefetch folder. We’ll also throw in a bonus tip for flushing your DNS cache — another hidden hoard that can cause slowdowns. For each one, we’ll give you exact, step-by-step instructions to find and clean them out safely. And at the end, we’ll hand you a single script you can run — and even schedule to run automatically every month — so this never sneaks up on you again.

Important: Before deleting anything, make sure you close all open applications. Some temporary files are actively used by running programs. Everything covered in this guide is safe to delete, but you should always use good judgment and avoid force-deleting files that Windows flags as in use.


The User Temp Folder — %temp%

Every time you install software, run an application, or Windows performs an update, files get dumped into a temporary folder tied to your user account. This is the User Temp folder, located at:

C:\Users\[YourUsername]\AppData\Local\Temp

The shortcut environment variable for this path is %temp%, and it works in both File Explorer and the Run dialog — making it the fastest way to get there. These files are meant to be temporary, but Windows almost never deletes them automatically. Over months or years, this folder can grow to 5–20 GB of wasted space.

What’s in there?

You’ll typically find installer leftovers, browser cache fragments, Office temporary files, crash dumps, and application logs. None of it is needed after the originating program closes — but it just sits there, accumulating.

Step-by-Step: How to Clean the User Temp Folder

  1. Press Windows Key + R on your keyboard to open the Run dialog.
  2. Type %temp% and press Enter.
  3. File Explorer will open directly inside your User Temp folder.
  4. Press Ctrl + A to select all files and folders.
  5. Press the Delete key (or right-click and choose Delete).
  6. If Windows prompts you that certain files are in use and cannot be deleted, click Skip — those files are actively being used and will be cleaned on the next pass.
  7. Empty your Recycle Bin to fully reclaim the disk space.

Command-line equivalent (run in Command Prompt as Administrator):

del /q /f /s "%temp%\*"
for /d %x in ("%temp%\*") do rd /s /q "%x"

The first line deletes all files. The second line removes all subdirectories. Any files that are currently locked by a running process will be skipped gracefully.


The System Temp Folder — %windir%\Temp

There’s a second Temp folder that operates at the system level rather than the user level. It lives at:

C:\Windows\Temp

The environment variable shortcut is %windir%\Temp. Unlike the User Temp folder, this one is written to by Windows system processes, services, and software installers that run with elevated (Administrator) privileges. It’s often even messier than the user temp folder — and because it requires admin rights to access, most users never even know it exists.

This folder routinely contains old Windows Update installation files, system diagnostic logs, crash reports, and service install packages. It’s common to find 2–10 GB of orphaned files here, and on heavily used systems or machines that have been through many Windows Updates, even more.

Step-by-Step: How to Clean the System Temp Folder

  1. Click the Start Menu and type cmd.
  2. Right-click on Command Prompt in the search results and choose “Run as administrator”. This is required — you won’t have permission to delete these files otherwise.
  3. In the Command Prompt window, type the following command and press Enter:
    batch
    del /q /f /s "%windir%\Temp\*"
  4. Then type the following to remove empty subdirectories:
    batch
    for /d %x in ("%windir%\Temp\*") do rd /s /q "%x"
  5. You may see a few “Access is denied” errors for files that are currently in use by Windows — this is normal and expected. Those files will be skipped.
  6. Once complete, you can verify the folder is emptied by typing:
    batch
    dir "%windir%\Temp"

Tip: You can also navigate to this folder manually by pressing Windows Key + R, typing %windir%\Temp, and pressing Enter. You may be prompted to confirm you want to access this restricted folder — click Continue.


The Prefetch Folder — C:\Windows\Prefetch

The Windows Prefetch folder is a lesser-known performance feature. When you launch an application, Windows takes a “snapshot” of what files and data the program needs to start up, and saves that snapshot as a .pf file in:

C:\Windows\Prefetch

The idea is that the next time you launch the same program, Windows can preload those files faster using the cached snapshot. It’s a genuinely useful feature — in theory. In practice, the Prefetch folder accumulates entries for every program you’ve ever run, including software you uninstalled years ago. It can contain hundreds of .pf files that correspond to programs that no longer even exist on your machine.

This folder typically ranges from 200 MB to 1+ GB. It won’t destroy your drive on its own, but combined with the other folders it adds up — and clearing it is completely safe. Windows will simply rebuild the cache over the following days as you use your computer.

Step-by-Step: How to Clean the Prefetch Folder

  1. Click the Start Menu and type cmd.
  2. Right-click on Command Prompt and choose “Run as administrator”.
  3. Type the following command and press Enter:
    batch
    del /q /f /s "C:\Windows\Prefetch\*"
  4. Windows may briefly report that one or two files are locked — skip these. The rest will be deleted.
  5. To verify, type:
    batch
    dir "C:\Windows\Prefetch"
  6. You can also access this folder manually: press Windows Key + R, type prefetch, and press Enter. If prompted for Administrator permission, click Continue. Select all with Ctrl + A and press Delete.

Note: Don’t be alarmed if your PC feels slightly slower for a day or two after clearing Prefetch. Windows is simply rebuilding the cache. Normal performance will resume quickly.


Bonus: Flush Your DNS Cache — ipconfig /flushdns

While not a folder per se, the Windows DNS cache is another hidden accumulation of data that can cause real problems. Every time you visit a website, Windows saves the DNS lookup result (the translation of a domain name like google.com into an IP address) in a local cache. This is meant to speed up future visits — but over time, the cache fills up with stale or corrupted entries.

A bloated or corrupt DNS cache can cause:

  • Websites failing to load even though your internet connection is fine
  • Slow DNS resolution times
  • Stale connections to old IP addresses for sites that have moved servers
  • Occasional “Page Not Found” errors that disappear after a flush

Flushing the DNS cache clears all of these stored entries and forces Windows to perform fresh lookups. It’s one of the most effective and underused troubleshooting steps for internet issues — and it takes less than five seconds.

Step-by-Step: How to Flush Your DNS Cache

  1. Click the Start Menu and type cmd.
  2. Right-click on Command Prompt and choose “Run as administrator”.
  3. Type the following command and press Enter:
    batch
    ipconfig /flushdns
  4. You should immediately see the confirmation message:
    “`
    Windows IP Configuration

Successfully flushed the DNS Resolver Cache.
“`
5. That’s it — your DNS cache is now cleared. Close Command Prompt.

Pro tip: If you’re troubleshooting an internet connectivity issue, always run ipconfig /flushdns before calling your ISP or rebooting your router. It solves the problem far more often than you’d expect.


Script All the Commands — Automate Your Cleanup

Now that you know what to clean and why, let’s make it effortless. The batch script below runs every single cleanup command from this article in one shot. Cut and paste it into a .bat file and you’ll have a one-click cleanup tool for your Windows PC.

Step 1: Create the Script File

  1. Click the Start Menu and type Notepad, then press Enter.
  2. Copy and paste the entire script below into Notepad.
  3. Click File → Save As.
  4. In the “Save as type” dropdown, select All Files (.).
  5. Name the file WindowsCleanup.bat and save it somewhere easy to find, such as your Desktop or C:\Scripts\.

The Cleanup Script

@echo off
:: ================================================
:: WindowsCleanup.bat
:: Cleans Windows Temp folders, Prefetch, and DNS
:: Run as Administrator
:: ================================================

echo ================================================
echo  Windows Disk Cleanup Script
echo  Running as Administrator required
echo ================================================
echo.

:: --- Clean User Temp Folder ---
echo [1/4] Cleaning User Temp folder (%temp%)...
del /q /f /s "%temp%\*" 2>nul
for /d %%x in ("%temp%\*") do rd /s /q "%%x" 2>nul
echo      Done.
echo.

:: --- Clean System Temp Folder ---
echo [2/4] Cleaning System Temp folder (%windir%\Temp)...
del /q /f /s "%windir%\Temp\*" 2>nul
for /d %%x in ("%windir%\Temp\*") do rd /s /q "%%x" 2>nul
echo      Done.
echo.

:: --- Clean Prefetch Folder ---
echo [3/4] Cleaning Prefetch folder (C:\Windows\Prefetch)...
del /q /f /s "C:\Windows\Prefetch\*" 2>nul
echo      Done.
echo.

:: --- Flush DNS Cache ---
echo [4/4] Flushing DNS cache...
ipconfig /flushdns
echo.

echo ================================================
echo  Cleanup Complete!
echo  Tip: Empty your Recycle Bin to fully reclaim
echo  disk space.
echo ================================================
pause

Important: You must right-click the .bat file and choose “Run as administrator” each time you use it. The System Temp and Prefetch folders require elevated privileges to clean.

Step 2: Schedule the Script to Run Monthly

Windows Task Scheduler lets you automate this cleanup so it runs hands-free once a month. Here’s how to set it up:

  1. Press Windows Key + S and search for Task Scheduler. Open it.
  2. In the right-hand panel, click “Create Basic Task…”
  3. Give it a name, such as Monthly Windows Cleanup, and an optional description. Click Next.
  4. Under Trigger, select Monthly and click Next.
  5. Set the day — for example, the 1st of every month — and choose a time when your PC is likely to be on and idle (e.g., 10:00 AM). Click Next.
  6. Under Action, select “Start a program” and click Next.
  7. Click Browse and navigate to where you saved WindowsCleanup.bat. Select it and click Open.
  8. Click Next, then check the box that says “Open the Properties dialog for this task when I click Finish”. Click Finish.
  9. In the Properties dialog that opens, go to the General tab.
  10. Check “Run with highest privileges” — this is critical, as the script needs administrator rights to clean the system folders.
  11. Click OK. You may be prompted for your Windows password to confirm.

Your cleanup script will now run automatically on the schedule you set. You can also trigger it manually at any time from Task Scheduler by right-clicking the task and choosing Run.

Tip: To verify the task is working, right-click it in Task Scheduler and choose Run immediately after setting it up. Check the “Last Run Result” column — a value of 0x0 means it completed successfully.


Summary

Windows is a powerful operating system, but it’s not always a tidy one. The three folders covered in this article — the User Temp folder, the System Temp folder, and the Prefetch folder — are silently accumulating gigabytes of data that your PC doesn’t need. Add a stale DNS cache to the mix and you’ve got a recipe for a sluggish, space-starved machine.

The good news: cleaning all of this up is straightforward, safe, and takes only a few minutes. Here’s a quick recap of what we covered:

  • %temp% (User Temp) — Application leftovers for your user account. Safe to delete entirely.
  • %windir%\Temp (System Temp) — System-level temporary files. Requires admin rights. Safe to delete.
  • C:\Windows\Prefetch — Program launch snapshots. Deleting them is safe; Windows rebuilds the cache automatically.
  • ipconfig /flushdns — Clears stale DNS entries. Instant fix for many mysterious internet issues.

By using the cleanup script and scheduling it to run monthly via Windows Task Scheduler, you can keep your drive lean and your system running at its best — completely hands-free. A few minutes of setup today will save you gigabytes of wasted space every single month.

Have questions or found another hidden Windows folder hoarding your disk space? Drop a comment below — we’d love to hear from you.