Goes to a label.
goto :mylabel echo Hello 1 REM Hello 1 never gets printed. :mylabel echo Hello 2 goto :eof echo Hello 3 REM Hello 3 never gets printed. Eof is a virtual label standing for the end of file.
Goto within the body of a for loop makes cmd forget about the loop, even if the label is within the same loop body.
$ goto /? Directs cmd.exe to a labeled line in a batch program. GOTO label label Specifies a text string used in the batch program as a label. You type a label on a line by itself, beginning with a colon. If Command Extensions are enabled GOTO changes as follows: GOTO command now accepts a target label of :EOF which transfers control to the end of the current batch script file. This is an easy way to exit a batch script file without defining a label. Type CALL /? for a description of extensions to the CALL command that make this feature useful.
Table Of Contents