How to Write a DOS Script
Scripts written for DOS are usually called batch files and have a ".bat" extension. Batch files are merely lists of DOS commands in text format, but they run just as an executable file would run. DOS scripts can be written to run by themselves or to receive input from a user. Each command entered will often include a variety of parameters to specify such things as which input is necessary, from where that input is received and what format the output should be in.
Instructions
-
-
1
Create an algorithm to determine precisely what you want the DOS script to do. This will help choose the appropriate commands and the order in which to use the commands.
-
2
Open your text editor and type the commands in one line at a time. As you type, imagine that each time you hit "Enter" your command will be executed. This will help ensure you have the proper command with all the necessary parameters in place.
-
-
3
Save the text file as a batch file. Most text editors will save a file with a ".txt" or ".rtf" extension, so you will have to change it to a ".bat" extension. For example, a batch file might be named "script.bat."
-
4
Run the batch file by typing the name of the file without the extension and pressing "Enter." Evaluate the performance of the script and if there are any errors, open the batch file in your text editor and correct them. Your command line must be pointing to the same directory as your script for it to run.
-
1
Tips & Warnings
Use the command "help" from the command prompt to see the different commands available and to see which parameters might be necessary for each command.
Do not use the file name "autorun.bat." This is used by DOS exclusively for scripts within the operating system that are intended to run automatically.