What batch is
unformatting text editor tools, e.g. the EDIT command in MS-
DOS. (some other methods will be discussed later)
A batch file must be named with an extension BAT, e.g.
autoexec.bat, menu.bat
A batch file is a program which contains MS-DOS commands.
Each command used in the batch file must be started from a
new line and written in a correct syntax. The syntax of a
command is just the same as that you use it at the DOS
prompt.
Im How does a batch file work? [ Top ]
Now, consider the following instructions for discussion.
md \newdir
copy \dos\*.exe \newdir
cd \newdir
dir
cd \
Executing commands at DOS prompt :
Normally, you can execute only one MS-DOS command at one
time (except you use a "trick"). You cannot give another
instruction before DOS has done your current command.
If you manually instruct DOS to execute the above commands,
you have to type each command at the DOS prompt one after
another.
Executing commands in a batch file:
However, if you put all of the commands in a text file in the
same manner as in the above box, it becomes an executable
program. Let's name it anyname.bat Similar to a COM or EXE
command, you can simply type the name of this batch file at
the DOS prompt to start your instructions. i.e. C:\> anyname
or C:\> anyname.bat (note: the extension bat is optional here.
It makes no difference, no matter you put it or not.)
DOS will then execute the commands automatically in the
same order as written in the anyname.bat The followings are
details of what DOS will do for you:-
1. Creates a new directory under the root called newdir
2. Copies all files under the DOS directory with an extension
of EXE to the newly created newdir directory.
3. Changes the current directory to newdir directory
4. Display the directory listing of newdir directory
5. Changes the current directory to root directory
Im What commands can you used in a batch file? [ Top ]
All commands that you can use at the DOS prompt can be
used in a batch file. You have to follow the same syntax of the
commands as you use it at the DOS prompt.
For advanced application of batch programs, the following nine
(9) special commands are commonly used. Some of them are
used together with special characters (details in next section).
CALL FOR PAUSE
CHOICE * GOTO REM
ECHO IF SHIFT
0 comments: