Esporta (0) Stampa
Espandi tutto
Arp
At
Cd
Cls
Cmd
Del
Dir
Fc
For
Ftp
If
Ldp
Lpq
Lpr
Md
Mmc
Msg
Nlb
Rcp
Rd
Reg
Rem
Ren
Rsh
Rsm
Rss
Sc
Set
Sfc
Ver
Vol
Espandi Riduci a icona
Questo argomento non è stato ancora valutato - Valuta questo argomento

Goto

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.

Syntax

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

  • 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:

    goto:EOF
    
  • 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.

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:

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

Il documento è risultato utile?
(1500 caratteri rimanenti)
Grazie per i commenti inviati.

Aggiunte alla community

AGGIUNGI
Mostra:
© 2014 Microsoft. Tutti i diritti riservati.