Batch File Yes or No to Continue
Download Article
Download Article
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
Click Start>Run
-
2
Type "cmd" (no quotations)
Advertisement
-
3
Type "edit"
-
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
@echo off (This command will 'hide' the command input - optional but recommended)
-
6
cls (This will clear anything above - optional but recommended if you're wanting to make it look neat)
- start
-
7
echo.
-
8
echo Choice 1 ("Choice 1" can be renamed to whatever you want, any of the choices)
-
9
echo Choice 2
-
10
echo Choice 3 (Keep doing that until you have all of the choices that you need.)
-
11
Type "set /p choice=(Insert question or command here, like "Yes or no?")
-
12
if not '%choice%'== set choice=%choice: ~0,1%
-
13
if '%choice%'=='1' goto :choice1
-
14
if '%choice%'=='2' goto :choice2
-
15
(Continue doing this pattern until you have enough. Then type:)
-
16
echo "%choice%" is not a valid option. Please try again.
-
17
echo.
-
18
goto start
-
19
After that you type:
- choice1
-
20
(commands you want to run)
-
21
-
22
(commands)
-
23
-
24
(commands)
-
25
goto end
-
26
Continue doing this pattern until you have completed the file.
- end
-
27
pause
-
28
exit
-
29
Save this as a .bat file. Double click to test your batch file.
Advertisement
Add New Question
-
Question
True or false: you can open Notepad using run options?
Felix Vincent
Community Answer
True, type in notepad or notepad.exe. Also, you can use CMD for that with "start Notepad."
Ask a Question
200 characters left
Include your email address to get a message when this question is answered.
Submit
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
-
Type choice /? in the Command Prompt for more info.
<b>Thanks! We're glad this was helpful.</b><br />Looking for more fun ways to learn on wikiHow?<br />Learn about yourself with <a href='/Quizzes'><b>Quizzes</b></a> or try our brand new <a href='/Games/Train-Your-Brain'><b>Train Your Brain</b></a> word game.
-
Type /help in the Command Prompt for more info.
<b>Thanks! We're glad this was helpful.</b><br />Looking for more fun ways to learn on wikiHow?<br />Learn about yourself with <a href='/Quizzes'><b>Quizzes</b></a> or try our brand new <a href='/Games/Train-Your-Brain'><b>Train Your Brain</b></a> word game.
-
Edit command in command prompt does not work in Windows 8. This command is available for windows XP/Vista/Windows 7.
<b>Thanks! We're glad this was helpful.</b><br />Looking for more fun ways to learn on wikiHow?<br />Learn about yourself with <a href='/Quizzes'><b>Quizzes</b></a> or try our brand new <a href='/Games/Train-Your-Brain'><b>Train Your Brain</b></a> word game.
Show More Tips
Thanks for submitting a tip for review!
Advertisement
-
Command that are used without knowledge may harm your computer.
<b>Thanks! We're glad this was helpful.</b><br />Looking for more fun ways to learn on wikiHow?<br />Learn about yourself with <a href='/Quizzes'><b>Quizzes</b></a> or try our brand new <a href='/Games/Train-Your-Brain'><b>Train Your Brain</b></a> word game.
-
Do not use commands unless you know what you are doing.
<b>Thanks! We're glad this was helpful.</b><br />Looking for more fun ways to learn on wikiHow?<br />Learn about yourself with <a href='/Quizzes'><b>Quizzes</b></a> or try our brand new <a href='/Games/Train-Your-Brain'><b>Train Your Brain</b></a> word game.
Advertisement
About This Article
Thanks to all authors for creating a page that has been read 234,836 times.
Is this article up to date?
Source: https://www.wikihow.com/Create-Options-or-Choices-in-a-Batch-File
0 Response to "Batch File Yes or No to Continue"
Post a Comment