Directs the operating system to a line in a batch program that is marked by a label you specify. You can use this command only in batch programs.
The GOTO command directs within a batch program to a line identified by a label. When the label is found, it processes the commands beginning on the next line.
GOTO /?
GOTO [:]label
IF
CALL
Equivalent Linux BASH commands:
case - Conditionally perform a command.
An easy way to exit a batch script file without defining a label is to specify "GOTO :eof" this transfers control to the end of the current batch file.
The label parameter cannot include separators such as spaces, semicolons or equal signs.
The GOTO command uses only the first eight characters of a label. Therefore, the labels 'hithere01' and 'hithere02' are both equivalent to 'hithere0'.
If two labels are the same (or just have the same first eight characters), the first label from the top of the BATCH file will be where processing will continue.
The label value you specify on the GOTO command-line must match a label in the batch program. The label within the batch program must be preceded by a colon.
If your batch program does not contain the label that you specify, the batch program stops and the operating system displays the message:
Label not found
The operating system recognizes a batch-program line beginning with a colon (:) as a label and does not process it as a command. If a line begins with a colon, the operating system ignores any commands on that line.
GOTO is often used on the same command-line with other commands to perform conditional operations. For more information about using GOTO for conditional operations, see the IF command.
This batch program formats a disk in drive A as a system disk. If the operation is successful, the GOTO command directs the operating system to a label named 'end'.
@ECHO OFF FORMAT A: /S IF NOT ERRORLEVEL 1 GOTO ERR ECHO An error occurred during formatting. GOTO END :ERR ECHO Successfully formatted the disk in drive A. :END
none.