WinXP BATCH file syntex help plz! =)

G

Guest

Thanks to who ever reads this and even those who can't
help with problem... =)

I am trying to make a BATCH file that has 4 items to
choose (1 through 4 as choices). I am having a hard time
getting the syntex correct with the IF and Set commands.
I am not sure if there is anything thing else needed. I
can create a simple 2 item menu okay. but when I get 3 or
more choices in the batch syntex I can't get it to work.

Can someone show me how to get the syntex written
correctly for this? All I need is the stuff after this
following line (that is if the following line is correct).

set /p answer=Enter Choice:

Thanks ever so much for this.. if you are wondering what
I am doing.. I am trying to put a menu for easy testing
of ping and tracert commands, but mostly ping wiht an
exit line.

Sincerely,

Kevin in Alaska
 
G

Guest

I forgot to add one thing.. it was an after thought...

Is there a way in the menu of the batch program to JUST
hit the selection and have it execute it or do you have
to make the selection THEN then Enter key to process the
selection.. I hope that makes sense... =/

Sincerely,

Kevin in Alaska
 
C

Code-Curious Mom

Try something like this (if that doesn't help post back to same thread with
what you've got that works with 2 choices):

@echo off
Set /p answer=Enter choice:
if %answer%==1 goto choice1
if %answer%==2 goto choice2
if %answer%==3 goto choice3
if %answer%==4 goto choice4
goto :EOF
:choice1
echo You chose number 1
echo.
REM do whatever for 1st choice
Pause
goto :EOF
:choice2
echo You chose number 2
REM do whatever for 2nd choice
Pause
goto :EOF
:choice3
echo You chose number 3
REM do whatever for 3rd choice
Pause
goto :EOF
:choice4
echo You chose number 4
REM do whatever for 4th choice
Pause

Once you get it working modify as needed.
I don't know of any way to avoid hitting the enter key, not sure if that's
possible using just a .bat file.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top