CMD Batch goto call command usage instructions _dos/bat

Source: Internet
Author: User
Tags extend goto modifier

First Batch goto command use Method
Directs cmd.exe to tagged rows in a batch program.

GOTO Label

label Specifies the text string used as a label in a batch program.

The label must be on a single line and preceded by a colon.

If the command extension is enabled, GOTO changes as follows:

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 an easy
Way. For an extended description of the call command that makes this feature useful, type
Call/?.

Look at the hints we need to know how to use the call command
Calls another batch program from a batch program.

Call [Drive:][path]filename [Batch-parameters]

batch-parameters Specifies the command line information required by the batch program.

If the command extension is enabled, call changes as follows:

The call command now accepts the label as the target of call. The syntax is:

Call:label arguments

A new batch file context is created by the specified parameter, which is controlled when the volume label is specified
Passed to the statement after. You must "exit" two times by reaching the end of the batch script file two times.
The first time you read the end of the file, the control returns to the back of the call statement. Second time
Will exit the batch script. Type GOTO/?, see the description of the goto:eof extension,
This description allows you to return from a batch script.


In addition, the batch script text parameter references (% 0,% 1, and so on) have been changed as follows:


%* in the batch script indicate all parameters (such as%1%2%3%5 ...)

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

%~1-Remove quotation marks ("), extending%1
%~F1-Extend%1 to a fully qualified pathname
%~D1-Extend%1 to only one drive letter
%~P1-Extend%1 only to one path
%~n1-Extend%1 only to a filename
%~X1-Extend%1 only to a file extension
%~S1-The path to the extension contains only the short name
%~A1-Extend%1 to file properties
%~T1-date/time the%1 was extended to a file
%~Z1-expands%1 to the size of the file
~ $PATH: 1-Find the directory listed in the PATH environment variable and add%1
Expands to the first fully qualified name found. If
The environment variable name is not defined, or the file is not found.
This modifier expands to an empty string

You can combine modifiers to achieve multiple results:

%~DP1-Extend%1 only to drive letters and paths
%~NX1-Extend%1 only to file name and extension
%~dp$path:1-Find% 1 in the directory listed in the PATH environment variable,
and extend to the drive letter and path of the first file found.
%~FTZA1-expands%1 to an output line similar to DIR.

In the example above,%1 and PATH can be replaced by other valid values.
The ~ syntax is terminated by a valid parameter number. The ~ modifier cannot be with%*
Use

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.