Page 1 of 1

IF not condition

Posted: 24 Mar 2011 03:38
by dukdpk
Hi All

when run Menu.bat file, it asks about select the option? options are as follows

1 Generate report staff
2 Generate report subjects
3 Generate report class
4 exit

My requirment is that when user enter incorrect option(i.e. not between 1 and 4) , I want to display message something like "you entered incorrect opntion, try again".

Thank You

Re: IF not condition

Posted: 24 Mar 2011 22:11
by dukdpk
Got the answer. answer is,

@echo off
:menu
1 Generate report staff
2 Generate report subjects
3 Generate report class
4 exit

echo.
set /p sample=Type option:

if "%sample%"=="1" call r1.bat
if "%sample%"=="2" call r2.bat
if "%sample%"=="3" call r3.bat
if "%sample%"=="4" goto Quit
if "%web%" gtr "4" goto Message
if "%web%" lss "1" goto Message


goto menu

:Message
echo you entered incorrect option

pause
goto menu

:Quit
exit