CMD batch processing goto call command instructions

Source: Internet
Author: User

How to use the first batch of goto commands
Direct cmd.exe to batch processingProgram.

Goto label

Label specifies the text string used as a label in the batch processing program.

The label must be a single line and start with a colon.

If the command extension is enabled, Goto will change as follows:

The Goto command now accepts the target Tag: EOF, which transfers control to the current
The end of the batch script file. Exit the batch script file without definition, which is easy
Method. For an extended description of the Call Command that can make this function useful, Type
Call /?.

We need to know how to use the call command.
Call another batch processing program from the batch processing program.

Call [drive:] [path] filename [batch-parameters]

Batch-parameters specifies the command line information required by the batch processing program.

If the command extension is enabled, the call will change as follows:

The call command now accepts the volume label as the call target. Syntax:

Call: Label arguments

A new batch file context is created by a specified parameter and controlled by the volume label
And then passed to the statement. You must "exit" twice by reaching the last two times of the batch script file.
When a file is read for the first time, the control will return to the end of the call statement. Second
Will exit the batch script. Type goto /?, See the Goto: EOF extension description,
This description allows you to return from a batch of scripts.

In addition, the batch script text parameter reference (% 0, % 1, etc.) has changed as follows:

% * In the batch script indicates all parameters (for example, % 1% 2% 3% 4% 5 ...)

The substitution of the batch parameter (% N) has been enhanced. You can use the following syntax:

% ~ 1-delete quotation marks ("), extended % 1
% ~ F1-extend % 1 to a fully qualified path name
% ~ D1-extend % 1 to only one drive letter
% ~ P1-only extend % 1 to one path
% ~ N1-extend % 1 to only one file name
% ~ X1-extend % 1 to only one file extension
% ~ S1-the extension path contains only short names
% ~ A1-extend % 1 to file attributes
% ~ T1-extend % 1 to the date/time of the file
% ~ Z1-extend % 1 to the file size
% ~ $ Path: 1-find the directory of the PATH environment variable and set % 1
Extend to the first fully qualified name found. If
The environment variable name is not defined, or the file is not found,
This modifier will be extended to an empty string

You can combine the modifier to obtain multiple results:

% ~ Dp1-extend % 1 to drive letter and path only
% ~ Nx1-only extend % 1 to the file name and extension
% ~ DP $ path: 1-find % 1 in the directory column in the PATH environment variable,
And extend to the drive letter and path of the first file.
% ~ Ftza1-extend % 1 to output rows similar to Dir.

in the preceding example, % 1 and path can be replaced by other valid values.
% ~ The syntax is terminated by a valid parameter number. % ~ The modifier cannot be used with % *

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.