Batch files help user to execute series of commands in the batch file. We can execute large number of commands in one go using bat file.
Some useful batch commands:
Some useful batch commands:
@echo off – does not echo the text post the command and only displayes the execution result
@echo on the text post the command and only displays the execution result
Pause- the batch file execution is halted until further intervention of user by pressing keys.
CALL - calling one batch file from another batch file
cd - Change directory
cls - clean the window
copy -copy files from source to destination
DIR - List of directory and files
ERASE - delete files
FC - Compares files
IF - Conditional statement
mkdir - Make a new directory/folder
move - move files or folder
ping - Check TCP/IP connection to a remote IP address
rmdir - remove folder/directory
SC - Managing services
set - manipulate environment variable
taskkill - kills an active process
taslist - List active processes
REM - remark statement
Arguments %1….. – This is the first argument to be provided from the
command prompt as parameter for the batch command.
Reference: http://www.robvanderwoude.com/batchcommands.php
Starting with batch files:
Let us take a simple example of using batch file to display Create a new file with extension as .bat. Suppose we need to compare two text files. The content of batch file for this will look like@echo off Fc %1 %2 /n>%3 Pause