Batch
files help user to execute a set of command to be executed in the defined order
by executing a batch file. We can execute large number of commands
in one go using bat file.
Creating a batch file
A batch file has extension .bat .To create a new bat file, we
can save a file in text editor like notepad in format .bat.
Some useful batch commands
@echo off – this will not echo the text post the command and will show only the execution result in the command prompt.
@echo on – this will echo the text post the command and will show the command as well as the execution result in the command prompt.
Pause– If we use pause, the batch file execution is halted until further intervention of user by pressing keys.
Arguments %1,%2,….. – This gives the parameter for the batch file.
echo val will display val in the command prompt
:: and rem can be used to add remarks to the script
Cls can be used to clear the command prompt
Example :
For
e.g we need to compare 2 txt files, but name of files to be compared needs to
be passed dynamically and log path also needs to be defined dynamically.