Goto


Applies To: Windows Vista,Windows Server 2008

Directs cmd.exe to a labeled line in a batch program. Within a batch program, goto directs command processing to a line that is identified by a label. When the label is found, processing continues starting with the commands that begin on the next line.

For examples of how to use this command, see Examples.

Syntax


Copy Code

goto <Label>

Parameters

Parameter

Description

<Label>

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

/?

Displays help at the command prompt.

Remarks


Copy Code

goto:EOF


Copy Code

:hithere0
:hithere01
:hithere02


Copy Code

Label not found

Examples

The following batch program formats a disk in drive A as a system disk. If the operation is successful, the goto command directs processing to the :end label:


Copy Code

echo off
format a: /s
if not errorlevel 1 goto end
echo An error occurred during formatting.
:end
echo End of batch program.

Additional references

Command-Line Syntax Key

Cmd

If