BATCH FILES Batch files are files with a .BAT extension which have a special function with DOS. They contain one or more lines of text which are the same as commands you can type at the command line. When you type the name of a batch file at the command line, it's lines are executed by DOS just as if you typed them at the command line yourself. A simple use of a batch file is to replace a long typing job at the command line with a short one. Let's say you want to start a program called STARGAME.EXE which happens to be in a sub-directory called D:\GAMES\MYGAMES\STARGAME. Normally you would have to type: D:\GAMES\MYGAMES\STARGAME\STARGAME.EXE Instead, you can create a batch file with any text editor or word processor which works in standard ASCII text mode and call it SG.BAT. SG.BAT can contain a single line of text: D:\GAMES\MYGAMES\STARGAME\STARGAME.EXE. Now, to start STARGAME all you have to do is type SG. Going a step further, let's say that you have to switch to the sub-directory containing STARGAME before you can run it, because the game itself needs to access files in it's directory. And, perhaps you are logged to a different disk. Normally you would have to type three lines before you could play the game: D: CD \GAMES\MYGAMES\STARGAME STARGAME If you wrap these three lines up in a batch file called SG, then you'll only have to type SG to start your game. Many programs come with their own batch files to make your life easier. Instead of having to look over a long list of files which come with the main program, you can just look for a start-up batch file. Common batch file names are BEGIN.BAT, GO.BAT and START.BAT. Other likely names are the same name as the program, or the initials of the program, followed by .BAT. If you have a program which comes with a start-up batch file, it is best to use it, rather than running the program directly, because start-up batch files may contain auxiliary information which your program needs to start properly. For instance, it may run differently depending on whether it is installed on a hard disk or floppy disk. The proper way to start will be contained in the batch file. Batch files can run most DOS commands including COPY, DIR, DEL, and CD, RD and MD. You can use combinations of these to accomplish tasks you do often. It is common to use MD to create a directory, then immediately switch to that directory. I've made myself a little batch file called ZD.BAT. It contains: MD \%1 CD \%1 %1 represents a variable, it is whatever you type on the command line after the batch file name. In this case, it is a new directory name. So, if I wanted a new directory called \FROG, I could simply type: ZD FROG and my new directory will be created. (Notice I don't even have to type the backslash, since the batch file does that for me. In addition to using the %1 variable, there are 8 more, %2 through %9, each one will pick up the next successive word, filename or directory name you type at the command line. If you were to create a batch file containing these lines: COPY %1 A: COPY %2 A: COPY %3 A: Then you could type the batch file name, followed by three filenames (separated by spaces) and they would all be copied to a floppy disk in the A drive. There is also a %0, which refers to the batch file itself. You can use it for such operations as making a self-deleting batch file. A batch file for installing a new program is useful only once, so you can add the line: DEL %0 to the end of the batch file, and it will disappear when it is done installing the program. Echo is a DOS command which will show whatever follows. So a batch file containing this line: ECHO Hello there! would display "Hello there!" when run. In a batch file containing other commands, your ECHO messages may not stay on the screen for very long, so you can use another DOS command called PAUSE, which will stop the batch file until the user presses any key. There is a DOS command called TYPE which will display up to a screenful of text at one time from any standard ASCII file. You can use this in batch files to display important information. Example: TYPE README.DOC AUTOEXEC.BAT There is a special batch file in the root directory of your hard disk called AUTOEXEC.BAT. When the computer is turned on, and DOS is loaded, it looks for this batch file. If found, it processes what it finds in AUTOEXEC.BAT right away. It is common for computers with Microsoft Windows installed to have an AUTOEXEC.BAT file containing the line WIN, to automatically start Windows everytime the computer is turned on. These basics will help you get started with batch files. There is much more to batch files, and whole books have been written about batch language programming. Special programs have also been written to extend the powers of batch files into processing math, asking for and processing user input, and displaying graphics. _____________________________________________ end of file.