Computing.Net > Forums > Programming > Bach menu help

Bach menu help

Reply to Message Icon

Original Message
Name: slapfish
Date: March 20, 2007 at 08:21:26 Pacific
Subject: Bach menu help
OS: Win XP SP2
CPU/Ram: CORE 2 T7200 / 1GB
Model/Manufacturer: ACER
Comment:

Hello,

I want to create a menu with 4 choices.
I found on previous post the way to do so,
but I want to exit the batch file if 5seconds passed without pressing a key. Is it possible?

thanks a lot



Report Offensive Message For Removal


Response Number 1
Name: tonysathre
Date: March 20, 2007 at 09:59:28 Pacific
Subject: Bach menu help
Reply: (edit)

There is no way to have a menu and a timeout. You can however have a timeout using ping, but it will not work with a menu. The following code will add a menu to your script with 4 options. Be sure to add your code under each label.

::==menu.bat
@echo off
for %%i in (1 2 3 4) do echo Choice %%i
echo Enter Choice:
set /p choice=
for %%a in (1 2 3 4) do (
if "%choice%"=="%%a" goto choice%%a
)

:choice1
::your code goes here

:choice2
::your code goes here

:choice3
::your code goes here

:choice4
::your code goes here

"Computer security." — Oxymoron


Report Offensive Follow Up For Removal

Response Number 2
Name: Mechanix2Go
Date: March 21, 2007 at 02:22:51 Pacific
Subject: Bach menu help
Reply: (edit)

@echo off
setLocal EnableDelayedExpansion

echo choose a menu item : 1 2 3 4
choice /c12345 /t5,5 /n
goto :%errorlevel%
:1
echo choice 1 & goto :eof
:2
echo choice 2 & goto :eof
:3
echo choice 3 & goto :eof
:4
echo choice 4 & goto :eof
:5



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal







Use following form to reply to current message:

   Name: From My Computing.Net Settings
 E-Mail: From My Computing.Net Settings

Subject: Bach menu help

Comments:

 


  Homepage URL (*): 
Homepage Title (*): 
         Image URL: 
 
Data Recovery Software




How often do you use Computing.Net?

Every Day
Once a Week
Once a Month
This Is My First Time!


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge