Tuesday, 15 October 2013

CALL

Sometimes it's handy to be able to run one batch file from another. Until DOS 3.3 you had
to resort to tricks to do that; without the tricks when you called a second batch file from a first then control would transfer to the second and you'd never get back to the first.

The command: CALL d:path\FILE NAME parameters
can be used in DOS versions 3.3 and later to start a second batch file from a parent and then return to the parent after the second finishes. Note: Do not use pipes or redirection on the second file.

The FILE NAME is the name of the second batch file; the parameters are any options that
the second file requires to properly run. When the second batch file terminates, control is returned
to the first batch file on the line following the CALL command.
You can simulate CALL in DOS versions lower than 3.3 by using:
COMMAND /C d:path\FILE NAME parameters In DOS 3.3 and later you can selectively cause lines in a batch file from being displayed. To cause this, place an "@" sign in front of the line in question.
One use of this would be to suppress showing the "ECHO OFF" command which is the
starting command of many batch files. Until the ECHO OFF command is actually executed, ECHO is ON and the command shows. To stop even this from showing make the first command: @ECHO OFF.

If you need to use the "@" feature with a command that already starts with @ (e.g.,
@WIP.EXE) then use a double @ (e.g., @@WIP) in the batch file (this should be rare).
Below are some simple batch file examples to whet your appetite.