FreeDOS help system (hhstndrd 1.0.8 en)[goto]

Command: goto

GOTO directs the command shell to a labelled line in a batch program. GOTO is a BATCH-FILE / AUTOEXEC.BAT command.

Syntax:

GOTO label

Options:

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

Comments:

The batch file will jump to the label and continue running from there. Use goto with the if command to control the flow of batch files. You type a label on a line by itself, beginning with a colon, e.g.: :LABEL1 The name of the label should be not to long AND self explaining. GOTO is a command internal to command.com and needs no other file in order to work.

Examples:

IN A .BAT FILE / AUTOEXEC.BAT: if %config%==1 goto DEFRAG if %config%==2 goto COPY :DEFRAG defrag c: goto END :COPY copy xy.txt c:\test\xy.txt goto END :END cls IN A .BAT FILE / AUTOEXEC.BAT: @ECHO 1 = Do this @ECHO 2 = Do that @ECHO 3 = Do another thing @ECHO 4 = Do nothing @choice /B /C:1234 /N /S What do you want to do? if errorlevel 4 goto DONOTHING if errorlevel 3 goto DOANOTHER if errorlevel 2 goto DOTHAT if errorlevel 1 goto DOTHIS :DOTHIS your commands goto EXIT :DOTHAT your commands goto EXIT :DOANOTHER your commands goto EXIT :DONOTHING your commands goto EXIT

See also:

autoexec.bat batch files choice if ------------------------------------------------------------------------------ Copyright (C) 2003 Robert Platt, updated 2007 by W. Spiegl. This file is derived from the FreeDOS Spec Command HOWTO. See the file H2Cpying for copying conditions.