A Batch File is a file written in basic DOS language that will execute the commands written within when you click on it. If you are unfamiliar with DOS, connect to Easydos.com for a minor education and a full list of DOS commands and what they do. In the examples given here, you will learn some of the basics of DOS.
Part 2 -- Batch Files have many uses. In Part 1, we saw how a simple Batch File could be used to back up your important files and folders. Here, we will use the Autoexec.bat file to clean up your Internet surfing tracks and Temp files.
A word about the Autoexec Batch file: The Autoexec (Auto-executable) file is located on the system drive, usually the C drive, as shown at right. This is a catchall batch file that operates during the bootup process. When Windows is freshly installed, it is blank, but as certain hardware or programming is added, commands are automatically written to the Autoexec file that tell the computer how to set up the hardware or program. This is an important file, so before we modify it, we will make a backup of the original Autoexec.
Right-click on the Autoexec file, and choose the "Edit" option. This opens the file in Notepad. Now, from the "File" tab at the top, choose the "Save as" option. When the Save window opens, simply type in the name "Autoexec-old.bat" and click "Save." Make sure you type in the ".bat" tag, as that converts it back into a batch file. You should now see two Autoexec files on your C drive, the original and the backup we just created. If you mess up the Autoexec.bat file, all you have to do is delete it and rename the "Autoexec-old.bat" to "Autoexec.bat." You'll be back to square one.
Editing the Autoexec.bat file: You edit it the same as you would any batch file, by right-clicking on it and selecting the "Edit" option from the menu. What you will see may be a blank page, but most likely it will have some sort of commands already written on it, as shown below. What we will be doing here is adding our text below everything else.

The first line we will add, cd windows, changes our directory to the Windows folder, where all our deletions will be made. We will also add a line, smartdrv, to start the "Smartdrive" program that resides in the Windows folder. Smartdrive will immensely speed up the deleting process. Deltree is a delete command, which removes the named folder completely from the hard drive. By adding the /y tag, we bypass the prompt asking if we want to delete each folder, making the command fully automatic. The folders we've selected to delete here are the Cookies folder, the History folder, the Temp folder, and the Temporary Internet Files folder (which in DOS is shortened to "tempor~1." See Part 1 for an explanation.). Of course, you can select your own lineup of folders to delete. For example, you may not want to delete your Cookies, so just skip that line. All but the "Temp" directory are automatically replaced by Windows as the computer boots up, but since the "Temp" folder won't be replaced, we add the line md temp, to create a replacement. (MD stands for "make directory"). Any such folders you delete that are not automatically replaced by Windows should be replaced in the same way. Take note, though, that all this activity is done in DOS mode, so you cannot create a directory with more than 8 characters in the filename, or with spaces in the name.
The Autoexec.bat file should now look like this ------->
Now you can close the Autoexec.bat file, saving your changes, and you should be ready to go. Reboot the computer. If you haven't regularly emptied your Temp folder or cleaned out your Temporary Internet Files, it may take quite a while to boot up to Windows, as you probably have thousands of files that are being deleted in the various folders. Don't get weirded out by this. After this initial cleaning, the boot time should be back to normal again.
This operation will take place every time you boot your computer, and will help keep your hard drive clean and stable.
Copyright 2009 Greenwood Technical