Automate Windows Cleanup with This Simple Batch Script

⏲️ Estimated reading time: 3 min

Automate Windows Cleanup with This Simple Batch Script
Keeping your Windows system clean and free from unnecessary temporary files is essential for maintaining optimal performance. Over time, temp files, cache, and other junk accumulate, taking up valuable space. Instead of manually clearing these files, you can automate the cleanup process using a simple batch script.

In this post, we’ll walk you through a powerful Windows cleanup script that removes temporary files, cache, and other unnecessary data in a few clicks. Simply run the script, and let it do the work for you!


Why Use This Script?

  • Frees Up Storage Space by deleting unnecessary temp files.
  • Boosts System Performance by cleaning up cache and redundant data.
  • Automates Cleanup instead of manually deleting files.
  • Restarts Explorer Automatically to refresh Windows after cleanup.

The Windows Cleanup Batch Script

Below is the batch script that automates the cleanup of temporary files, caches, and other system clutter.

@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


How to Use This Script

  1. Copy and Paste the Code into Notepad.
  2. Save the File as cleanup.bat (Make sure to select “All Files” under file type).
  3. Run as Administrator (Right-click the cleanup.bat file and select “Run as administrator”).
  4. Watch the Magic Happen! The script will clean up temp files, cache, and restart Explorer automatically.

FAQs

1. Is it safe to run this script?
Yes! This script only removes unnecessary temporary files and caches that Windows automatically regenerates. It does not delete essential system files.

2. How often should I run this script?
You can run it once a week or whenever you notice your system slowing down.

3. Can I automate this script?
Yes! You can schedule it using Windows Task Scheduler to run at regular intervals.


Conclusion
Using this simple batch script, you can quickly free up disk space, speed up your PC, and keep Windows running smoothly without any manual effort. Try it out and let us know in the comments if you found it helpful!

🚀 Have any suggestions or improvements for the script? Share them below!

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

Automate Windows Cleanup with This Simple Batch Script

Published

Update

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