Top Nav

Windows Tip: Automatically Clean the Temp Folder During Boot

Windows always has temp files and other junk that’s just taking up space on your hard drive. We’ve covered several ways to clean up the extra junk by using Disk Cleanup to using third-party utilities like CCleaner.

For more, check out our article: Five Ways to Reclaim Windows Disk Space.

Most of the methods in that article end up cleaning out the Temp folder, but you might want to keep that folder as clean as possible. Here’s how to create a bat file that will allow you to clean out the Temp file each time you boot up.

Windows Temp File

First, let’s take a look at the Temp folder in Windows. To get to it in Windows 7 type: %temp% in search field in the Start menu, or on Windows 8.1, hit the Windows Key and type the same thing from the Start menu and hit Enter.

temp

That opens the Temp folder, and if you want to clean it out manually, just hit Ctrl + A to  select everything in it, and then Delete. Not all of the files and folders will be deleted though as those files are currently in use.

In fact, you really don’t want to delete any temp files that were created since you booted up the PC for performance sake.

Windows Temp Folder

Create a Batch File to Automatically Clean Temp Folder

A lot of space can end up being saved on your hard drive by clearing out the Temp file. And if you shut down your PC every night, you can safely delete the temp files from the previous day during boot.

Open Notepad and type in the following:

rd %temp% /s /q

md %temp%

Now, save the file exactly as the path below:

%appdata%\microsoft\windows\start menu\programs\startup\cleantemp.bat

That will create your batch file and save it inside the Startup folder.

bat file

After creating the batch file, I rebooted my PC and opened the Temp folder, you can see there’s far fewer files in it compared to the image above.

after reboot

While Windows 8.x doesn’t have a Start menu, it has the Startup folder – here’s how to find it. So the cool thing is that the instructions above will work in both versions.

More Reading:

, ,

19 Responses to Windows Tip: Automatically Clean the Temp Folder During Boot

  1. Ziggy September 24, 2014 at 7:26 pm #

    Very nice, Brian. Like it!

    Here’s another great free tool to clean junk from one’s computer: AFT Cleaner…

    Link: http://www.softpedia.com/get/Security/Secure-cleaning/ATF-Cleaner.shtml

    • Ziggy September 25, 2014 at 7:33 pm #

      Oops! My comment should read ATF Cleaner NOT AFT Cleaner. Apologies…

  2. Cho September 25, 2014 at 10:37 am #

    trying it …… hope nothing breaks….

  3. wcrewson September 25, 2014 at 10:48 am #

    Hi used the tip for cleaning temp worked Perfectly, Thanks

  4. wheelsey_4 September 28, 2014 at 5:58 pm #

    Brian, after my laptop restarted, a command prompt showed up saying that file could not be used for some reason I did not have time to copy before it closed on its own. Any suggestions?

    • Brian Burgess September 29, 2014 at 3:49 pm #

      @wheelsey_4: When the process runs during startup to clean out the temp file, a command prompt will display briefly then go away.

      If you’re getting an error message, I am thinking it might be because it’s telling you a certain file cannot be deleted due to a program needing it?

      I guess I don’t know for sure unless you can get the exact error.

      • wheelsey_4 September 29, 2014 at 6:25 pm #

        Thanks, yeah, it worked. It cleaned out a crap load of stuff. Thanks

  5. DZinCA December 13, 2014 at 4:37 pm #

    Hello Brian,
    Thank you very much. This helps a lot. I was getting sick of constantly going to the folder to empty the files.

    I have a related question. Would you kindly let me if there are bat files to empty the windows’ temp folder? That too gets filled, as well the “windows\softwareDistribution\download”?

    Many thanks again and Merry Christmas!
    Cheers,
    D

  6. dagan March 29, 2015 at 11:32 am #

    how does one UNDO this? – -I can’t install a certain program because of it

    • Jeff Dunlop April 11, 2015 at 6:04 pm #

      You can’t undo this unless you have backups of your temp folder which I would never do. I’d bring up your issue with the program that’s using your temp folder as an appdata folder.

  7. Jeff Dunlop April 11, 2015 at 6:03 pm #

    Nice tip. I’ve been doing this manually for ages and this greatly simplifies things. It’s annoying that programs use the temp folder as a garbage dump when by definition if the process exits normally it should clean up its crap.

  8. Brian Q October 27, 2015 at 4:25 pm #

    Great help! Thanks for sharing!

  9. Venu November 24, 2015 at 3:55 am #

    Hello

    thank for the tip and..can we delete some of other cache folders which created by visual studio..

  10. H January 2, 2016 at 5:19 am #

    What in case of Windows XP?

  11. AK February 11, 2016 at 9:00 am #

    Is it a one time batch or you need to run it whenever you want to clear your temp files automatically.
    Awaiting your response.

    Regards,
    Ahmed

  12. wheelsey_4 May 31, 2016 at 7:40 pm #

    Can I, now, delete that file?

  13. Ahmed Alaa August 6, 2016 at 2:39 pm #

    its very simple to remove all temp files in windows 7 64bit or 32bit, just do the below :
    1- open (RUN) and write %temp% then ENTER.
    2- you will find that all temp files in that folder, just remove what you want.

    Thank You

  14. thatdudejbob October 10, 2016 at 7:01 pm #

    Thank you very much for this tutorial.
    It was very easy to follow and works perfectly.

    To anyone looking to do this, I highly recommend it.
    You will not have any regrets in the matter.

  15. Ikay October 19, 2016 at 2:18 pm #

    Thanks for this..but how do I stop the command from loading everytime I boot. It takes time before I’m able to use my laptop after booting.

Leave a Reply