Goto Batchfiles

The goto command moves a batch file to a specific label or location, enabling a user to rerun it or skip other lines depending on inputs or events.

  1. Goto Batch Files
  2. How To Write A Batch File
  3. Batch File Goto Label
  4. If Exist Goto Batch File

Availability

Goto accepts the use of variable value to act as the label to goto. Example: @echo off echo a = 1 echo b = 2 set /p 'foo=Enter option:' goto%foo% However, you should check the input so it will not go to somewhere that does not exist. Batch files are DOS command line commands batched together. In Linux they are known as shell scripts, and follow a completely different syntax. Early Windows users had to use a batch file (autoexec.bat) to allocate a drive letter to their.

Goto is an internal command that is available in the following Microsoft operating systems.

Goto syntax

Goto Batch Files

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

You type a label on a line by itself, beginning with a colon.

Windows 2000, Windows XP, and later additional syntax

If Command Extensions are enabled GOTO changes as follows:

Goto

GOTO command now accepts a target label of :EOF that transfers control to the end of the current batch script file, which exits without defining a label. Type CALL /? for a description of extensions to the CALL command that make this feature useful.

FileGoto batch files download

Goto examples

How To Write A Batch File

In the example below, the batch file would only print 'DONE,' skipping anything that is between the GOTO and the GOTO target label.

Batch File Goto Label

Additional information

If Exist Goto Batch File

  • See the goto definition for additional information and related links on this term.