Executing commands in a batch file
Posted: 24 Sep 2014 07:29
Hi Friends,
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:-
Creates a new directory under the root called newdir
Copies all files under the DOS directory with an extension of EXE to the newly created newdir directory.
Changes the current directory to newdir directory
Display the directory listing of newdir directory
Changes the current directory to root directory
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:-
Creates a new directory under the root called newdir
Copies all files under the DOS directory with an extension of EXE to the newly created newdir directory.
Changes the current directory to newdir directory
Display the directory listing of newdir directory
Changes the current directory to root directory