goto
Windows CMD · Terminal · reference only
What it does
Jumps to a label in a .bat script and continues execution from there. It allows loops, menus and early exits.
Syntax
goto etiqueta
Options and parameters
etiquetaName of the label to jump to.
:nombreThis is how a label is defined in the script, at the start of a line.
:eofSpecial label that goes to the end of the script or ends a subroutine.
/?Shows the command's help.
Usage examples
goto finJumps to the :fin line of the script.
if "%1"=="" goto usoIf the parameter is missing, jumps to a label that explains the usage.
goto :eofEnds the script or the current subroutine.
goto menuGoes back to an earlier label to repeat a menu.
Notes and common mistakes
- goto only works inside a script, not typed directly in the console.
- A label that does not exist causes an error and stops the script.