Search notes:

cmd.exe: goto

goto is affected by whether command extensions are enabled or disabled.

Let the user choose an option

The following example uses set /p to print Choose either foo, bar or baz! and assign the entered option to the environment variable %chosen%.
It then uses if … equ … to compare the entered value to the hard coded values foo, bar or baz. Depending on the chosen value, the if statement then uses goto to jump to a label which simply prints what the user has chosen.
@echo off

:choose
@set /p chosen="Choose either foo, bar or baz! "

if "%chosen%" equ "foo" goto foo_chosen
if "%chosen%" equ "bar" goto bar_chosen
if "%chosen%" equ "baz" goto baz_chosen

@echo "YOu haven't chosen a valid option, try again!"
goto choose

:foo_chosen
@echo Here's Foo
@goto finish

:bar_chosen
@echo Here's Bar
@goto finish

:baz_chosen
@echo Here's Baz

:finish
Github repository about-cmd.exe, path: /commands/goto/menu.bat

See also

Other cmd.exe commands

Index

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Windows/...', 1759952831, '216.73.216.10', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Windows/dirs/Windows/System32/cmd_exe/commands/goto/index(72): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78