Batch files are a list of command line instructions that are “batched” together in one file. Most of the command lines can be executed within the command prompt, but batch files make the work load much easier. Batch files can be opened, copied, and edited .
Batch files, more or less, make up the backbone of the Windows Operating System. The operating system must have access to these files and be able to add and delete instructions from them. Delete them, and you have effectively disabled the OS.
Basic Batch and Commands
Note: Any DOS command can be used within a , below are a list of commands used to support the and flow of the batch file
Place @ in front of commands that you don’t want echoed within the process.
Clears the screen of any previous data.
Calls another batch file. Once other batch file isfinished, control is returned to the first (i.e. CALL c:WindowsNewbat.bat).
When turned on within the batch file, the user has an option of stopping the batch file by bressing Ctrl+Break.
GOTO – This command is used to go to another section of the batch file. Sections can be added by adding a colon infront of a name
(i.e. :FIRSTSECTION, :SECONDSECTION):
REM Welcome to the first section
REM Welcome to the second section
It is possible to loop with the GOTO command:
REM NO!!!!!!!!!!!!!!!!!! IT’S LOOPING!!!!!!!!!!!!!
The pause command halts a proccess until a key is hit by the user. Displays the message, “Press any key to continue…”
Allows a remark to be placed within , displaying a message to the user (i.e. REM HELLO!).
Command process is shown to user; @ is usually placed before (@ECHO ON).
Command process is not shown to the user; @ is usually placed before (@ECHO OFF).
Ends the process.
Simple Batch Programming to show Hello message is :
echo “hello world”
ype this code into notepad and save it with .bat extenstion(For eg: hello.bat)
By double clicking the batch file,you can run. Above batch file will show the hello world but we can’ see it. because the window will open and closed within a second.
We will see later how to see it.