batch-file – Using Goto – Goto with variable

Goto accepts the use of variable value to act as the label to goto.

Example:

@echo off

echo a = 1
echo b = 2

set /p "foo=Enter option:"
goto %foo%

However, you should check the input so it will not go to somewhere that does not exist. Going to an undefined label will terminate your batch script instantly.

if you want to reproduce, please indicate the source:
batch-file – Using Goto – Goto with variable - CodeDay