Making a MENU in xp Batch files???

  • Thread starter Thread starter Guest
  • Start date Start date
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.

One last Question.. is there a way, once the batch file
is created to set it up further where when a selection is
made you don't have to hit enter after you make the
selection... (e.g. instead of "1 then ENTER" you can just
hit "1" and the command precesses)???

Sincerely,

Kevin in Alaska
 
wrote in message <SNIP> > I am trying to make a BATCH file <SNIP>

You may want to try posting in the following Microsoft Newsgroup:

microsoft.public.win2000.cmdprompt.admin

Your newsgroup message header seems to indicate that you are posting to the Microsoft
Public Newsgroups using the Microsoft Communities Web Page. If I am correct, if you
click the first link below it will open your browser to:

Microsoft Communities Newsgroups Web Interface:
microsoft.public.win2000.cmdprompt.admin
http://communities2.microsoft.com/c...min&cat=en-us-servers-winserver&lang=en&cr=US

If you read newsgroups using a NNTP newsreader, such as Outlook Express, and
use the msnews.microsoft.com news server, here is a link:
news://msnews.microsoft.com/microsoft.public.win2000.cmdprompt.admin
 
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.
 
Back
Top