Are you really good at programming Batch Files, but you just don't know how to make those yes or no Choices or Menus that list Choices 1, 2, and 3? Well you've come to the correct place!

Steps

  1. 1
    Click Start>Run
  2. 2
    Type "cmd" (no quotations)
    Advertisement
  3. 3
    Type "edit"
  4. 4
    Type the following, careless of bolded/unbolded worlds. After each press enter. Anything in parenthesis do NOT type, these are side-notes that tries to explain the steps.
  5. 5
    @echo off (This command will 'hide' the command input - optional but recommended)
  6. 6
  7. 7
    echo.
  8. 8
    echo Choice 1 ("Choice 1" can be renamed to whatever you want, any of the choices)
  9. 9
    echo Choice 2
  10. 10
    echo Choice 3 (Keep doing that until you have all of the choices that you need.)
  11. 11
    Type "set /p choice=(Insert question or command here, like "Yes or no?")
  12. 12
    if not '%choice%'== set choice=%choice:~0,1%
  13. 13
    if '%choice%'=='1' goto :choice1
  14. 14
    if '%choice%'=='2' goto :choice2
  15. 15
    (Continue doing this pattern until you have enough. Then type:)
  16. 16
    echo "%choice%" is not a valid option. Please try again.
  17. 17
    echo.
  18. 18
    goto start
  19. 19
  20. 20
    (commands you want to run)
  21. 21
  22. 22
    (commands)
  23. 23
  24. 24
    (commands)
  25. 25
    goto end
  26. 26
  27. 27
    pause
  28. 28
    exit
  29. 29
    Save this as a .bat file. Double click to test your batch file.
  30. Advertisement

Community Q&A

  • Question
    True or false: you can open Notepad using run options?
    Felix Vincent
    Felix Vincent
    Community Answer
    True, type in notepad or notepad.exe. Also, you can use CMD for that with "start Notepad."
Advertisement

Example

@ECHO off
cls
:start
ECHO.
ECHO 1. Print Hello
ECHO 2. Print Bye
ECHO 3. Print Test
set /p choice=Type the number to print text.
rem if not '%choice%'=='' set choice=%choice:~0;1% ( don`t use this command, because it takes only first digit in the case you type more digits. After that for example choice 23455666 is choice 2 and you get "bye"
if '%choice%'=='' ECHO "%choice%" is not valid please try again
if '%choice%'=='1' goto hello
if '%choice%'=='2' goto bye
if '%choice%'=='3' goto test
ECHO.
goto start
:hello
ECHO HELLO
goto end
:bye
ECHO BYE
goto end
:test
ECHO TEST
goto end
:end
pause
exit

Warnings

Advertisement

About This Article

Tested by:
wikiHow Technology Team
wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, 13 people, some anonymous, worked to edit and improve it over time. This article has been viewed 239,622 times.
How helpful is this?
Co-authors: 13
Updated: July 11, 2022
Views: 239,622
Categories: Programming
Advertisement