About Mikazo Tech Blog

My name is Mike, and this blog is my way of saving people time. If someone has a specific problem that I've encountered before, hopefully these posts will save them the extraneous Googling I had to go through to solve the same problem. Also, when I have something to say about technology today, I will post my thoughts here. If this blog has helped you out, even a little bit, vote on the poll below, or let me know by sending me an email. I'm always open to exchanging links with other blogs or websites that share a similar interest.

Monday, January 5, 2009

Using the Task Scheduler to Clean Your Temporary Files

An often overlooked feature of Windows is the Task Scheduler, used to perform menial tasks at specific times, to save you having to remember to do them. In a few short minutes, you can create your own tasks to clean your computer of temporary files, scan for spyware and viruses, and execute any program you like.

The Task Scheduler can be accessed by opening Control Panel, then Administrative tools, then Task Scheduler. Upon opening the Task Scheduler on my HP laptop, I immediately noticed a few tasks that I did not want to run, so I removed them by right-clicking the task, then choosing Delete. Some tasks I removed included HP Health Check, Internet Provider Offers, and some other stuff. It doesn't hurt to check if you have any annoyances scheduled, and then you can remove them.

To create a task that removes unneeded temporary files, first start by opening Notepad. Copy and paste the following lines into a new file, then save it as clean.bat somewhere (I used my Documents folder). Be sure to set the "Save as type" field to "All files" when saving.


cd c:\windows\temp
del /Q /F /S *.*
cd %temp%
del /Q /F /S *.*


These commands switch to the Windows temporary directory and the user temporary directory, respectively. The del command should remove all files in each directory. The /Q tag is for quiet, asking no confirmation. The /F tag is for force deletion of read-only files. The /S tag is for subdirectories, delete files in each subdirectory. The *.* makes use of the wildcard character, meaning delete files with any name and any extension.

You have now just created a batch file, which is a simple text file containing a list of command-line commands to be executed in a specific order.

I have been deleting files from these directories for a long time, and as far as I can tell, it is completely safe to empty these directories. I have never run into a problem as a result of emptying my temp folders. Do not worry if some files cannot be deleted, as they are probably currently in use by the operating system.

Now that you have your batch file, open up the Task Scheduler, select Create Basic Task... and name it something like "Clean temporary files". On the next screen, to keep things simple, select "When the computer starts". On the next screen, select "Start a program". On the final screen, browse to where you saved your clean.bat file. On the final screen, check off "Open the properties dialog..." and click Finish.

In the properties dialog, you can change various settings if you like. The only change I made was under the Conditions tab, where I unchecked "Start the task only if the computer is on AC power (since I am running this on a laptop). Select OK and your task is complete.

Your computer will now clean up after itself every time it starts, giving you a fresh slate for your next work session.

0 comments:

Donate to Mikazo Tech Blog