Let’s Make a Batch File to Clean Up Your PC

By | September 19, 2016
Print pagePDF page

Let’s Make a Batch File to Clean Up Your PC

This tip will work on Windows 7, Windows 8, Windows 8.1 and Windows 10. So have at it!

Back in the days of yore — i.e. DOS — batch files were used by geeks to do all sorts of things – including some bad things. Batch files are still as powerful as ever. Geeks use them but that doesn’t mean they’re hard to create. Actually there are very easy to make. All you need to make one is Notepad, a little code, and a little patience.

So open Notepad right now. Press and hold down the Windows Key — then press the R key. In the command line type Notepad and press Enter. Now that Notepad is open copy and paste the following line (or if you’re a masochist you can type it all in):

c:\windows\system32\cleanmgr.exe /dc

Now, and this is VERY important! Make sure you select “All files” in Notepad’s Save as type dialog. If you leave it set as “Text Documents”- your batch file won’t work, because text files cannot execute. (See the helpful image below.)

Cloudeight InfoAVe

Now that you have Save as type “All files” chosen, save your file as cleanup.bat . Saving it to your desktop is highly convenient because it’s right there where you can see it. Amaze your friends! Even your enemies! You are a geek – you just created a program!

Here’s another way to do it. This creates a shortcut to Windows Disk Cleanup – so it’s not so geeky but you can pin the shortcut your taskbar or Start menu if you choose.

Go to your desktop. Right-click on an empty area (one with no icons). Choose “New” then “Shortcut” and copy & paste this line of text:

c:\windows\system32\cleanmgr.exe /dc


Then click “Next” and give your Disk Cleanup Shortcut a name:


And click “Finish”.

If you want your shortcut to appear on your start menu or taskbar (or both), just right-click it and choose “Pin to start” or “Pin to taskbar” or both. See?

So whether you want to play around with making a batch file and amaze your cronies, or if you just want a nifty shortcut to clean up your computer, now you know how, right?

 

8 thoughts on “Let’s Make a Batch File to Clean Up Your PC

  1. Geoff

    So. . . you describe HOW to make a batch file.
    Can you describe WHAT this one will do?

    Reply
  2. Bernie Woiwod

    Hi Thundercloud
    I now have a shortcut to Disk Cleanup but what is it safe to cleanup?
    Is it safe to tick ALL the boxes?
    I have SYSTEM ERROR MEMORY DUMP FILES 3.24 GB.
    Can I clean up that?

    Bernie

    Reply
    1. infoave Post author

      Anything that shows in the main window you can remove safely…however if you delete the dump files you won’t be able to use them to trouble shoot. That being said, when’s the last time you used them to troubleshoot?

      According to Microsoft:

      A dump file is a snapshot of an app at the point in time the dump is taken. It shows what process was executing and what modules were loaded. If the dump was saved with heap information, the dump file contains a snapshot of what was in the app’s memory at that point in time.

      Reply
  3. A_Hippy_Hillbillie

    Do not forget to run Command Prompt as administrator; copy and paste from notepad into it:
    c:\windows\system32\cleanmgr.exe /dc Once you do that, hit enter and watch cleanup in action!

    Reply
    1. infoave Post author

      You don’t need to run Command Prompt as an admin to run it. You don’t need to type the whole command line either. You can run it from any Command Prompt – all you have to type is cleanmgr and pres Enter.

      You don’t even need to run it from a Command Prompt at all. You can run it from a Run box – Windows Key + R , type cleanmgr in the run box and press enter.

      Thanks!

      Reply
  4. patrick

    Why go through all of this. Click on start menu, type clean then right click on disk cleanup icon and pin to start menu or task bar. Now you have an easy shortcut.

    Reply
    1. infoave Post author

      Cuz it’s educational Batch files are very powerful, and very easy to make. This one is harmless but many are not. You’re right you can click start and then right-click disk cleanup when it shows up and choose Pin to Taskbar and/or Pin to Start. Not much learning there for sure.

      Here’s one you can’t do so easily any other way than a batch file:

      Open Notepad: Copy & Paste the following:

      @echo off
      color 02
      :mobydick
      echo %random%%random%%random%%random%%random%%random%%random%%random%
      goto mobydick

      Save it as fun.bat or whatever you want as long as you save it as .bat file ( Notepad will save files as text unless you choose “All files” when you’re saving it. It won’t work if you save it as text.

      Fun with batch files.

      Reply

Leave a Reply to A_Hippy_Hillbillie Cancel reply

Your email address will not be published. Required fields are marked *