Multiple IF in CMD

February 20, 2010 at 03:44:30
Specs: Windows Vista
Hi all,
I wanted to use a batch file that gave you a choice of 1-3 and and if anything other than 1-3 was entered, the batch file would say its incorrect and go back to the question.
I tried using IF commands but my coding is pretty terrible so had no success.

Any help with this will be greatly appreciated. Thanks!

See More: Multiple IF in CMD

Report •

February 20, 2010 at 04:22:44
This is not elegant, but works.

@echo off & setLocal EnableDELAYedeXpansion

set /p C=choose 1, 2 or 3
if !C! neq 1 (
if !C! neq 2 (
if !C! neq 3 (
echo !C! is not OK && goto :input

echo !C! is OK
echo processing choice !C!

Helping others achieve escape felicity


Report •

February 20, 2010 at 05:41:19
@echo off

set /p answer=Enter your choice (1-3):
if NOT "%answer%"=="1" if NOT "%answer%"=="2" if NOT "%answer%"=="3" goto question
echo Your answer was correct: %answer%

Report •

February 20, 2010 at 07:34:16
Thanks that perfect! :D

Report •
Related Solutions

Ask Question