IF not condition

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
dukdpk
Posts: 13
Joined: 10 Mar 2011 03:27

IF not condition

#1 Post by dukdpk » 24 Mar 2011 03:38

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

dukdpk
Posts: 13
Joined: 10 Mar 2011 03:27

Re: IF not condition

#2 Post by dukdpk » 24 Mar 2011 22:11

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

Post Reply