Sign in with
Sign up | Sign in
Your question

How to make "multiple choise" batch files

Last response: in Windows 2000/NT
Share
January 9, 2003 10:40:12 AM

HI,
I have been tried to make Multiple Choice batch file
in w2000. CHOICE is not recognized as an internal or external command. Where I can find (working) Multiple batch examples or does anyone know how to do these in W2K.

@ECHO OFF

:BEGIN
CLS

CHOICE /N /C:123 PICK A NUMBER (1, 2, or 3)%1

IF ERRORLEVEL ==3 GOTO THREE
IF ERRORLEVEL ==2 GOTO TWO
IF ERRORLEVEL ==1 GOTO ONE
GOTO END
:THREE
ECHO Hello World
GOTO END
:TWO
ECHO Hello World 2
GOTO END
:o NE
ECHO Hello World 1
:END



<P ID="edit"><FONT SIZE=-1><EM>Edited by savoc on 01/09/03 07:42 AM.</EM></FONT></P>
January 9, 2003 11:58:58 AM

use the set /p command like so:
<pre>set /p RESP=Which one?
echo Response: %RESP%
</pre><p>Try it out for yourself.

<i>It's always the one thing you never suspected.</i>
January 13, 2003 7:00:47 AM

Thaks, "SET" really works.

@echo off
echo.
echo Pick one:
echo.
echo 1. Apple
echo 2. Orange
echo 3. Potato
echo 4. Banana
echo 5. Tomato
echo 6. Melon
echo 7. EXIT
echo.
:choice
Echo Hit a number [1-7] and press enter.
set /P CH=[1-7]
if "%CH%"=="1" goto apple
if "%CH%"=="2" goto orange
if "%CH%"=="3" goto potato
if "%CH%"=="4" goto banana
if "%CH%"=="5" goto tomato
if "%CH%"=="6" goto melon
if "%CH%"=="7" goto quit
...
!