Step 8GOTO Command
To use this command, you must first have a label in place. Labels look like this:
:Label1It's simply a colon before a non-spaced series of letters and/or numbers.
The GOTO command is structured like this:
GOTO Label1It's That Easy!
Come to think of it, I'm not really sure why I didn't put this in the Slightly Advanced Batch.
In any case, this command can be used to repeat a batch file by simply GOTO a label that executes the GOTO command again.
@ECHO OFF:RepeatMeECHO This will be repeated unless you hit "CTRL-C"GOTO RepeatMeThe batch file speaks the truth, by the way. CTRL-C is the universal Pause and Prompt for Termination. CTRL-S is simply Pause. But Closing the window works just as well.
The GOTO can skip, or reorder your code as well.
GOTO TurnEOffGOTO MultipleGotoECHO This ECHO is going to be skipped.:MultipleGotoGOTO 3:ENDPAUSEEXIT:1ECHO The EndGOTO END:3ECHO This will be displayed firstGOTO 2:TurnEOff@ECHO OFFGOTO MultipleGoto:2ECHO This is second, even though it's last in the code.GOTO 1The above code was structured confusingly on purpose to emphasize the GOTO's ability to jump around in the code.
| « Previous Step | Download PDFView All Steps | Next Step » |
1
comment
|
Add Comment
|
![]() |
Add Comment
|




















































