Aggiornamento: settembre 2007
Si applica a: Windows Server 2008, Windows Vista
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.
Specifies a text string that is used as a label in the batch program.
Displays help at the command prompt.
Working with command extensions
If command extensions are enabled (the default), and you use the goto command with a target label of :EOF, you transfer control to the end of the current batch script file and exit the batch script file without defining a label. When you use goto with the :EOF label, you must insert a colon before the label. For example:
Using valid Label values
You can use spaces in the Label parameter, but you cannot include other separators (for example, semicolons or equal signs). The goto command uses only the first eight characters of a label. For example, the following labels are equivalent and resolve to :hithere0:
:hithere0 :hithere01 :hithere02
Matching Label with the label in the batch program
The Label value that you specify must match a label in the batch program. The label within the batch program must begin with a colon (:). If a line begins with a colon, it is treated as a label and any commands on that line are ignored. If your batch program does not contain the label that you specify in Label, the batch program stops and displays the following message:
Label not found
Using goto for conditional operations
You can use goto with other commands to perform conditional operations. For more information about using goto for conditional operations, see the If command reference.
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:
echo off format a: /s if not errorlevel 1 goto end echo An error occurred during formatting. :end echo End of batch program.
Si desidera partecipare?