Instructions for using the CMD batch goto call command

Time:2021-5-11

How to use the first batch goto command
take   cmd.exe   Direct to the labeled line in the batch program.

GOTO label

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

The label must be on a single line and begin with a colon.

If command extension is enabled, goto   It will change as follows:

GOTO   The command now accepts the target tag  : EOF, this tag transfers control to the current
The end of the batch script file. It’s easy to exit a batch script file without defining it
way. What makes this function useful   CALL   For an extended description of the command, type
CALL /?。

We need to know how to use the call command
Call 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.

Call if command extension is enabled   It will change as follows:

CALL   The command now treats the volume label as   CALL   The goal of acceptance. The grammar is:

    CALL:label arguments

A new batch file context is created by the specified parameters, and the control is specified in the volume label
After passing to the statement. You have to do this by reaching the last two times of the batch script file  ” exit”   twice.
At the end of the file for the first time, control returns to   CALL   Immediately after the statement. The second time
The batch script exits. typing   GOTO  /?, see   GOTO  : EOF   Extended description,
This description allows you to return from a batch script.

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

      In batch script  %*  Indicate all parameters (e.g  % one  % two  % three  % four  % five  …)

      Substitution of batch parameter (% n) has been enhanced. You can use the following syntax:

         %~ one          –  Delete quotation marks (“), extend  % one
         %~ f1         –  take  % one   Extend to a fully qualified pathname
         %~ d1         –  Only  % one   Extend to one drive letter
         %~ p1         –  Only  % one   Extend to a path
        %~n1         –  Only  % one   Extend to a file name
         %~ x1         –  Only  % one   Extend to a file extension
         %~ s1         –  The extended path contains only short names
         %~ a1         –  take  % one   Extend to file properties
         %~ t1         –  take  % one   Date / time extended to file
         %~ z1         –  take  % one   Expand to file size
         %~$ PATH:1    –  Find column in   PATH   The directory of the environment variable, and the  % one
                        Extend to the first fully qualified name found. If
                        The environment variable name is not defined or the file is not found,
                        This modifier extends to an empty string

     You can combine modifiers to achieve multiple results:

        %~ dp1        –  Only  % one   Extend to drive letter and path
        %~ nx1        –  Only  % one   Extend to file name and extension
        %~ dp$PATH:1  –  Listed in   PATH   Environment variables in the directory to find  % 1,
                       And expand to the drive letter and path of the first file found.
        %~ ftza1      –  take  % one   Extend to similar   DIR   The output line of the.

     In the example above,% 1   and   PATH   Can be replaced by other valid values.
    %~  The syntax was terminated by a valid parameter number~   Modifier cannot follow  %*
     use

Recommended Today

Looking for frustration 1.0

I believe you have a basic understanding of trust in yesterday’s article. Today we will give a complete introduction to trust. Why choose rust It’s a language that gives everyone the ability to build reliable and efficient software. You can’t write unsafe code here (unsafe block is not in the scope of discussion). Most of […]