A Helpful Batch File for Windows Users

I like other OSes, but Windows is the Big Kahuna in eyeshare, so naturally I share more Windows tips here than anything else for any other OS. Just the way it is. That said, here’s a lil tip for Windows users to help keep down the accumulated junk a Windows install just naturally crufts up with.

First run “cleanmgr /sageset:99”

Oh, right. Start>Run and copy-paste the above material found between the quotation marks–just don’t include the quotation marks. Win 7 users, just hit the Start Orb and paste it in the search field and hit enter.

Choose files you wish deleted, actions to be taken, apply, then close.

Then copy the text below, paste it into a plain text editor like Notepad and save it as a batch file. Replace “%username%” with your username. Place it in a “tools” folder or some such to use as desired or in your startup folder if that’s your preference.

The switches selected for the del command below are

f=force deleting of read-only files.
q=quiet mode; do not ask if ok to delete on global wildcard
s=delete specified files from all subdirectories.

c:
cd “C:\Users\%username%\Local Settings\Temp”
del /q /s /f *.*
cd “C:\Users\%username%\Local Settings\Temporary Internet Files”
del /q /s /f *.*
cleanmgr /sagerun:99

Sure, cleanmgr will attempt to clean up TEMP files and Temporary Internet files for you, but it just does a so-so job. By including the first two “del” commands, you’re assured that those WILL be deleted.

Oh, you could also download, install and run CCleaner (“Crap Cleaner”), but even it doesn’t necessarily get rid of read-only files located in the TEMP and Temporary Internet Files folders. It’ll try, but…

2 Replies to “A Helpful Batch File for Windows Users”

  1. User temp files are below “C:\Documents and Settungs\%Username%\…” on XP I believe. (no, the ellipsis isn’t part of the path, I’m just too lazy to really look up the rest of it).

    1. Yeh, Perri, ending with “Local Settings\Temp\etc., for XP and 2000 (in fact, I actually began running this lil batch file on a Win2K program some time ago), but I elided over the differences in locations for multiple reasons. Folks who are moderately advanced users (the ones who will know how to save a plain text document as a batch file *heh*) will likely already know XP and 2000 have user info stored in a different place and can modify the path should they wish to use this. “Less advanced” users? Well, they can still get in trouble by being too aggressive with their sageset picks, but not much, and if they don’t modify the path. well, the batch file will simply run and do nothing on the “del” commands since they’ll find nothing to delete at the locations specified.

      So, yeh, it’s a filter of sorts.

      Plus, I was just too lazy to put all that “old stuff” in. *heh*

Leave a Reply

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