|
|
Objective:
What's
a batch file? [ Top ]
| md \newdir
copy \dos\*.exe \newdir cd \newdir dir cd \ |
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.
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:-
|
|
|
|
|
|
|
|
|
|
|
|
| * CHOICE is an external DOS command.
Please ensure the current path statement contains C:\DOS when you need to run a batch program in which the CHOICE command is used. |
||
|
|
|
|
|
|
| Name: | batch display suppression
operator |
batch file label operator | batch replaceable
parameter |
batch replaceable
parameter |
| Syntax: |
|
|
|
|
| Example: |
|
:option1 | %1, %2, %3 etc. | %%1, %%2 etc. |
| Remarks | -- | -- | -- | used with FOR command only |
| A sample batch file named
greeting.bat |
Batch file executed in
DOS prompt |
| @echo off
echo %1 is %2 echo |
c:\>greeting
IOS100 fun
IOS100 is fun (<-- i.e. the output) |
|
|
|
|
|
|
|
|
|
|
|
|