How To Clean Windows With a Batch Script File

⏲️ Estimated reading time: 4 min


Want to speed up your Windows PC? Use this powerful batch script to Clean Windows temp files, cache, recent documents, and even restart Explorer in seconds no software needed!


🚀 Why Use a Batch Script to Clean Your PC?

Over time, your Windows PC accumulates a lot of unnecessary data like temporary files, old caches, and system leftovers. These slow down your system and take up valuable space. A batch script can help clean them up quickly no manual steps or third-party apps needed.


⚙️ What This Script Does

This batch script performs the following tasks:

  • Deletes all temporary files from system and user folders
  • Clears browser and system cache
  • Empties the recycle bin
  • Flushes DNS cache
  • Frees up space instantly

📄 The Batch Script Code

@echo off
title Windows System Cleaner
color 0a

echo Cleaning temporary files...
del /q /f /s %TEMP%\*
del /q /f /s C:\Windows\Temp\*

echo Cleaning Windows cache...
cleanmgr /sagerun:1

echo Flushing DNS cache...
ipconfig /flushdns

echo Emptying recycle bin...
rd /s /q %systemdrive%\$Recycle.Bin

echo All done! Your system is cleaner and faster.
pause

🛠️ How to Use It

  1. Open Notepad.
  2. Paste the code above.
  3. Save it as cleaner.bat.
  4. Right-click the file and choose Run as administrator.
  5. Wait for the cleanup to finish!

⚠️ Important Notes

  • Make sure to close all programs before running the script.
  • Always back up important data.
  • Some actions require administrator privileges.

🧼 Bonus Tips for Better Performance

  • Uninstall unused programs
  • Disable startup apps
  • Update Windows regularly
  • Defragment your hard drive (for HDDs only)

🧹 Clean Windows with a Batch Script File: Delete Temp, Cache & Recycle Bin

Manually deleting temp files or cache folders can be tedious. This powerful Clean Windows bat script will automate the cleanup of:

  • System and user temp folders
  • Prefetch cache
  • Recycle Bin
  • Recent files and destinations
  • Automatically restarts Windows Explorer for a smooth finish
Clean Windows With a Batch Script

📜 The Batch Script

Copy the following code into a text file and save it with a .bat extension (e.g., Clean Windows.bat). Then, right-click and run as Administrator.

@echo off
cls
echo Cleaning temporary and cache files...

:: System Temp
del /s /f /q "%windir%\Temp\*.*" >nul 2>&1
rd /s /q "%windir%\Temp" >nul 2>&1
md "%windir%\Temp"

:: Prefetch
del /s /f /q "%windir%\Prefetch\*.*" >nul 2>&1
rd /s /q "%windir%\Prefetch" >nul 2>&1
md "%windir%\Prefetch"

:: Recycle Bin
del /s /f /q "%SystemDrive%\$Recycle.bin\*.*" >nul 2>&1
rd /s /q "%SystemDrive%\$Recycle.bin" >nul 2>&1
md "%SystemDrive%\$Recycle.bin"

:: User Temp
del /s /f /q "%temp%\*.*" >nul 2>&1
rd /s /q "%temp%" >nul 2>&1
md "%temp%"

:: Recent Files
del /s /f /q "%APPDATA%\Microsoft\Windows\Recent\*.*" >nul 2>&1
rd /s /q "%APPDATA%\Microsoft\Windows\Recent" >nul 2>&1
md "%APPDATA%\Microsoft\Windows\Recent"

:: Automatic Destinations
del /s /f /q "%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations\*.*" >nul 2>&1
rd /s /q "%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations" >nul 2>&1
md "%APPDATA%\Microsoft\Windows\Recent\AutomaticDestinations"

:: Custom Destinations
del /s /f /q "%APPDATA%\Microsoft\Windows\Recent\CustomDestinations\*.*" >nul 2>&1
rd /s /q "%APPDATA%\Microsoft\Windows\Recent\CustomDestinations" >nul 2>&1
md "%APPDATA%\Microsoft\Windows\Recent\CustomDestinations"

:: Restart Explorer
taskkill /f /im explorer.exe >nul 2>&1
start explorer.exe

echo Cleanup complete.
pause

Clean Windows batch script

⚠️ Important Notes

  • Always run the script as Administrator.
  • Backup important data before using.
  • Avoid using while critical tasks are running.

This script is great for periodic maintenance to keep your system running smoother and free up disk space.

📩 Do you have questions or suggestions? Leave a comment or contact us!

🏷️ Tags: windows cleanup, batch file, delete temp files, free up disk space, speed up pc, windows maintenance, recycle bin cleaner, cache cleaner, system script, tech tips

Report an issue (max 5 words):

Only logged-in users can submit reports.


Discover more from HelpZone

Subscribe to get the latest posts sent to your email.

Want to support us? Let friends in on the secret and share your favorite post!

Photo of author

Flo

How To Clean Windows With a Batch Script File

Published

Welcome to HelpZone.blog, your go-to hub for expert insights, practical tips, and in-depth guides across technology, lifestyle, business, entertainment, and more! Our team of passionate writers and industry experts is dedicated to bringing you the latest trends, how-to tutorials, and valuable advice to enhance your daily life. Whether you're exploring WordPress tricks, gaming insights, travel hacks, or investment strategies, HelpZone is here to empower you with knowledge. Stay informed, stay inspired because learning never stops! 🚀

👍 Like us on Facebook!

Closing in 10 seconds

Leave a Reply