It seems that a cmd script containing:
prog1
prog2
does the same as
call prog1
call prog2
What is the point of using the CALL command ?
You can run the commands stored in a CMD file in Windows by double-clicking the file or executing it in the Command Prompt (CMD. EXE) utility. You cannot run CMD files in COMMAND.COM, like you may do with BAT files, so that you do not incorrectly execute commands in the wrong Windows environment.
Windows Command Prompt (also known as the command line, cmd.exe or simply cmd) is a command shell based on the MS-DOS operating system from the 1980s that enables a user to interact directly with the operating system.
You can test command line arguments by running an executable from the "Command Prompt" in Windows or from the "DOS prompt" in older versions of Windows. You can also use command line arguments in program shortcuts, or when running an application by using Start -> Run. This will start notepad with a blank document.
You should use call
when you either want to:
A command file with the line:
number2.cmd
will chain to the number2.cmd
file, meaning it will run that script but not return to continue execution on the current one.
As to the second point, you can do things like:
call :subroutine
call :subroutine
goto :eof
:subroutine
echo in here
goto :eof
and you will get in here
printed twice. This ability to call functions within command scripts is actually quite handy.
You should use call
when you need to call another batch program (cmd script). Using 'call' will have no effect if prog1
is an executable file. (prog1.exe
)
If you, for example, have two scripts:
cmd1.cmd
cmd2.cmd
And within cmd1.cmd
you have a line:
cmd2.cmd
... then your script will stop as soon as cmd2.cmd
is finished executing. Instead you should use:
call cmd2.cmd
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With