It's clunky, but can be done:
======================
:AGAIN
@ECHO [1] Thing One
@ECHO [2] Thing Two
@SET /P MYPICK="Choose One:"
@IF %MYPICK%==1 GOTO :ONE
@IF %MYPICK%==2 GOTO :TWO
@ECHO "ERROR, Invalid Input: %MYPICK%"
@GOTO :AGAIN
:ONE
@ECHO "Doing Thing One"
@GOTO :END
:TWO
@ECHO "Doing Thing Two"
@GOTO :END
:END
@ECHO DONE
PAUSE
===========================
2007-08-23 13:10:03
·
answer #1
·
answered by McFate 7
·
0⤊
3⤋
First, I would use the "choice" command in the batch.
Second, I would name my various sub-functions the same as possible keypresses. This way you don't have to do a lot of checking of "if keypress==1, then goto one", "if keypress==2, then goto two". You simply CALL the subfunction using the %errorlevel% given by the users choice.
Finally, you need a good way to loop back to the menu and a clean way to get out, too.
It would go something like,
==================================
@echo off
:MENU
cls
echo 1. ONE batch
echo 2. TWO batch
echo 3. THREE batch
echo 4. FOUR batch
echo 5. FIVE batch
echo 6. EXIT
choice /c:123456 Pick a number:
call :%errorlevel%
goto :EOF
:1
echo You chose to run option ONE & pause
goto :MENU
:2
echo You chose to run option TWO & pause
goto :MENU
:3
echo You chose to run option THREE & pause
goto :MENU
:4
echo You chose to run option FOUR & pause
goto :MENU
:5
echo You chose to run option FIVE & pause
goto :MENU
:6
echo You chose to EXIT
goto :EOF
=============================
Another option,
=============================
If you don't want to use 'choice', then "set /p" can work, but I would still just CALL to the subfunction instead of adding a lot of code to check each option.
@echo off
:MENU
cls
echo 1. ONE batch
echo 2. TWO batch
echo 3. THREE batch
echo 4. FOUR batch
echo 5. FIVE batch
echo 6. EXIT
set /p CHOICE="Pick a number and hit ENTER: "
goto :%CHOICE%
goto :EOF
:1
echo You chose to run option ONE & pause
goto :MENU
:2
echo You chose to run option TWO & pause
goto :MENU
:3
echo You chose to run option THREE & pause
goto :MENU
:4
echo You chose to run option FOUR & pause
goto :MENU
:5
echo You chose to run option FIVE & pause
goto :MENU
:6
echo You chose to EXIT
goto :EOF
========================
Final notes,
"Set /p" is nice because it's a built-in DOS function. The downside is that people can enter an incorrect choice.
"Choice" is nice because nothing happens unless the user presses one of the values that you have predetermined. The downside is that you need to have this command on your system, but it does come with Windows/DOS.
2007-08-24 13:01:22
·
answer #2
·
answered by Kevin 7
·
4⤊
0⤋
Windows, and DOS before it, have the weakest batch file system I've ever seen. In your case, the biggest hurdle is getting the user's choice into the file. I can't recall or find any way of doing this short of a small specialized program. Even interpreting a simple Y or N response requires one, and there isn't any.
In any other command line script language or shell, you'd put up a series of lines with selection numbers before them, ask the user to pick one, read in their response and fall through a conditional sieve (IF ... THEN... ELSEIF ...THEN ....ENDIF) deciding which one you got and acting on it accordingly. In DOS batch files, even the IF statement is so weak you have to jump through hoops to construct a sieve.
2007-08-23 12:46:05
·
answer #3
·
answered by The Phlebob 7
·
0⤊
2⤋
batch convert multiple .avi data to .vob data or video dvd format data, i understand a sturdy software RZ DVD writer can try this properly, purely run it, then press decision button to characteristic multiple conversion threads in decision communique to augment velocity while convert multiple video data to .vob data or video dvd format data, it could convert any format video data to vob data or mpeg data, or promptly convert to video dvd, uncomplicated to apply, and it could shop the switched over data on annoying stress, or promptly burn to any DVD disc, it grant the extra helpful high quality, extra applications, and quicker velocity. you could yahoo or google seek RZ DVD writer and acquire it, wish it could assist you to.
2016-11-13 07:07:44
·
answer #4
·
answered by ? 4
·
0⤊
0⤋
First of all I have to ask...why are you using .bat files? They are extremely limited and no one uses them anymore.
But to answer your question you basically have to have it print out text on screen like.
1) go to windows
2) boot linux
then you have to ask the user for input then you have to make an if/else statement
guide:
http://www.chebucto.ns.ca/~ak621/DOS/BatBasic.html
2007-08-23 12:18:01
·
answer #5
·
answered by Redchaos 4
·
0⤊
2⤋