I have a batch file which calls another batch file that exists in PATH directory (basically calling an executable with additional switches.)
: bar.bat:
foo.bat file1.txt
foo.bat file2.txt
etc.
In foo.bat:
foo.exe -t -s %1
bar.bat executes the first command but exits immidately (i.e. working on file1.txt only).
How can I make this batch file to invoke the other batch file more than once?
Use the CALL keyword:
In addition to @splattne's answer, use
exit /b
in theCALL
ed batch file if you need to return early.Another option (for compatibility with DOS prior to version 3.3 :-) ) is to call the command process with the child (/c) option and the name of the other batch file to process. That will also do a call instead of a chain, and will even work on truly ancient machines (just in case someone runs across this and cares). :-)
@echo off
echo WbLegalReport.cmd
i:
cd I:\CFS\Batch\jarDir
echo %CD%
WbLegalReport.cmd
echo %CD%
echo WatchResrAddDeleted.cmd
echo %CD%
WatchRestrAddDeleted.cmd
echo %CD%
What I am trying to do here is call these two batch files in a sequence.
Unable to do so.
help please.
Acutally it is failing at the child script, As the control does not return back to the main script
Sanket, don't call the batch file directly. Use the "CALL" command. See splattne's example.