Explore this Article
X
wikiHow is a “wiki,” similar to Wikipedia, which means that many of our articles are co-written by multiple authors. To create this article, 12 people, some anonymous, worked to edit and improve it over time.
The wikiHow Tech Team also followed the article's instructions and verified that they work.
This article has been viewed 225,464 times.
Learn more...
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
-
1Click Start>Run
-
2Type "cmd" (no quotations)Advertisement
-
3Type "edit"
-
4Type 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@echo off (This command will 'hide' the command input - optional but recommended)
-
6cls (This will clear anything above - optional but recommended if you're wanting to make it look neat)
-
7:start
-
8echo.
-
9echo Choice 1 ("Choice 1" can be renamed to whatever you want, any of the choices)
-
10echo Choice 2
-
11echo Choice 3 (Keep doing that until you have all of the choices that you need.)
-
12Type "set /p choice=(Insert question or command here, like "Yes or no?")
-
13if not '%choice%'== set choice=%choice:~0,1%
-
14if '%choice%'=='1' goto :choice1
-
15if '%choice%'=='2' goto :choice2
-
16(Continue doing this pattern until you have enough. Then type:)
-
17echo "%choice%" is not a valid option. Please try again.
-
18echo.
-
19goto start
-
20After that you type:
-
21:choice1
-
22(commands you want to run)
-
23goto end
-
24:choice2
-
25(commands)
-
26goto end
-
27:choice3
-
28(commands)
-
29goto end
-
30Continue doing this pattern until you have completed the file.
-
31:end
-
32pause
-
33exit
-
34Save this as a .bat file. Double click to test your batch file.Advertisement
Community Q&A
-
QuestionTrue or false: you can open Notepad using run options?
Felix VincentCommunity AnswerTrue, type in notepad or notepad.exe. Also, you can use CMD for that with "start Notepad."
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
- Command that are used without knowledge may harm your computer.Thanks!
- Do not use commands unless you know what you are doing.Thanks!
Advertisement
You Might Also Like

How to
Become a Programmer

How to
Learn a Programming Language

How to
Convert from Binary to Decimal

How to
Format Text as Code in Discord

How to
Download a File from GitHub

How to
View Source Code

How to
Create a Programming Language

How to
Delay a Batch File

How to
Make an Exe File

How to
Code

How to
Write Pseudocode

How to
Download a GitHub Folder

How to
Start Learning Computer Programming

How to
Start XAMPP at Startup in Windows
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, 12 people, some anonymous, worked to edit and improve it over time. This article has been viewed 225,464 times.
How helpful is this?
Co-authors: 12
Updated: April 2, 2020
Views: 225,464
Categories: Programming
Advertisement



