Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the Call command in dos

Shulou Source: shulou.com Published: 2022-06-03 06:28:59 09月18日 Update

This article mainly introduces how to use the Call command in dos. It is very detailed and has a certain reference value. Friends who are interested must finish it!

Call

Calls from one batch program to another without terminating the parent batch program. The call command accepts the label that is used as the target of the call. If you use Call outside of a script or batch file, it will not work on the command line.

Grammar

Call [[Drive:] [Path] FileName [BatchParameters]] [: label [arguments]]

Parameters.

[Drive:} [Path] FileName

Specifies the location and name of the batch program to be called. The filename parameter must have a .bat or .cmd extension.

BatchParameters

Specify 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 label to which the batch program jumps. Use the call command with this parameter to create a new batch file context and give control to the statement after the specified label. 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 instructions on the goto: eof command extension that allows you to return from a batch script, see ".

Arguments

For batch programs that start with: label, specify the command line information to pass to its new instance, including command line options, file names, batch parameters (from% 1 to% 9), or variables (such as% baud%).

/?

Displays help at the command prompt.

Annotation

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 about batch parameters, see.

Use pipes and redirect symbol

Do not use pipes and redirection symbols in the call command.

Issue a recursive call

You can create a batch program that calls itself, but you must provide an exit condition. Otherwise, the parent and child batch programs can loop indefinitely.

Use command extension

If command extension is enabled (that is, by default), call accepts the label parameter as the target of the call. The correct syntax is as follows:

Call: label arguments

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

Example

To run the Checknew.bat 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 them to Checknew.bat, you can use the following command in the parent batch program:

Call checknew 1 2

The above is all the contents of the article "how to use Call commands in dos". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Commands programs parameters files information labels variables file names scripts statements content control endings targets symbols pipes articles syntax help control Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Huawei Xiaomi NVidia Shulou Information