A batch file is normally a text file with Windows Command Line commands. It has to carry an extension .bat. Filename can be anything you wish.
You may see autoexec.bat in Windows drive -> root folder. Autoexec means automatic running of the commands contained in the batch file. This file executes all commands between Windows booting and Welcome Screen. Normally, the autoexec.bat is an empty file. You may use it to create your own maintenance system. If you do not wish to delay the process of Windows startup, you can create a batch file with any other name and run it later.
A batch file can be created for any purpose. All you need is sound knowledge of Windows Command Line commands and Notepad. There are some special batch file commands that help you create a perfect maintenance program.
We will create a simple batch file to clean the C drive as the computer starts:
1 Hit Windows key and then the R key on your keyboard. Type Notepad in Run Dialog and hit Enter to open Notepad.
2. As we intend to delete all junk files from the C drive, we will save it in the root directory. Press CTRL +S and in the Save as Dialog, type C:\CleanJunk.bat. Make sure that in the Save As Type box, you select All Files (*.*) else it will be saved as a text file.
3. Type Del C:\*.tmp /S as the first line in the Notepad and hit Enter for next line. Refer to the Windows Command Line Guide, Part I, for information on Del command.
4. Type Del C:\*.log /S in the second line.
5. Save and close the file.
Our batch file is ready. The /S option checks each subfolder in C drive's root folder - meaning, all folders will be scanned.
To run the batch file, all you need to do is to open the C drive and double click on the CleanJunk.bat file. To run it from RUN, type C:\CleanJunk to run the file. As the file runs, it scans all root and subfolders for .tmp files and deletes them. Then it comes to the second command and repeats the process for all .log files.
This is just a simple batch file that cleans your C drive. You can create a batch file - of any complexity - to maintain Windows and thereby automate and speed up computer tasks.