SoFunction
Updated on 2025-04-08

Call calls another batch program from one batch program and does not terminate the parent batch program.

Call
Call another batch from one batch and does not terminate the parent batch. The call command accepts the tag used as the call target. If you use Call outside a script or batch file, it will not work on the command line.

grammar
call [[Drive:][Path] FileName [BatchParameters]] [:label [arguments]]

parameter
[Drive:}[Path] FileName 
Specifies the location and name of the batch program to be called. The filename parameter must have an extension of .bat  or .cmd.
BatchParameters 
Specifies any command line information required by the batch program, including command line options, file names, batch parameters (from %0 to %9), or variables (for example, %baud%).
:label 
Specifies the tag to which the batch program wants to jump. Use the call command with this parameter to create a new batch file context and hand over control to statements after the specified tag. When the end of the batch file is first encountered (after jumping to the tag), control is returned to the statement after the CALL statement. The second time you encounter the end of the batch file, the batch script will be exited. For the goto:eof command extension that allows you to return from a batch script, see "" for instructions on it.
arguments 
For batch programs headed by :label, specify the command line information to be passed to its new instance, including command line options, file names, batch parameters (from %1 to %9), or variables (such as %baud%).
/? 
Show help in the command prompt.
Comments
Use batch parameters
Batch parameters can contain any information passed to the batch program, including command line options, file names, batch parameters (from %1 to %9), or variables (for example, %baud%). For more information on batch parameters, see "".

Use pipelines and redirect symbols
Do not use pipes and redirect symbols in the call command.

Issue a recursive call
A batch process that calls itself can be created, but an exit condition must be provided. Otherwise, the parent and child batch programs can loop infinitely.

Use command extension
If command extension is enabled (i.e. by default), call will accept the label parameter as the call target. The correct syntax is as follows:

call :label arguments

For more information on enabling and disabling command extensions, see cmd in "".

example
To run a program from another batch program, type the following command in the parent batch program:

call checknew 

If the parent batch program accepts two batch parameters and wants it to pass these parameters to  , you can use the following command in the parent batch program:

call checknew %1 %2 

XOX