"goto" - Change the Execution Flow

Q

What is the "goto" batch command for?

✍: FYIcenter.com

A

The "goto" command is for changing the execution flow in a batch file.

Below is the "if" command syntax:

goto label

When the "goto" command is executed, the execution will jump to the line where "label" is defined and continue to execution the line after the "label".

Here is an example on how to use the "goto" command:

@ECHO OFF
FORMAT a: /s
IF NOT errorlevel 1 GOTO end
ECHO An error occurred during formatting.
:end
ECHO End of batch program.

 

"for" - Loop on List of Files

"if" - Run Command Conditionally

Using Batch Commands

⇑⇑ Windows Batch File Tutorials

2022-08-26, 1715🔥, 0💬