Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I've created a batch file with a menu inside, 1 to 7 choices. When I execute the batch file, the DOS window pops and closes right away and I don't know why. I've even done a search on google for batch files with menus and they all do the same thing. Could it be Windows XP???

Post your batchfile so we can have a look at it. There are so many things what can be wrong.
I don't think this is because WinXP but I'm not sure.

A batch menu like this will likely open and close instantly on WinXP:
@echo off
echo Choose:
echo [1] Option 1
echo [2] Option 2
CHOICE /c:12While in Win9x the CHOICE.COM command is present by default and will wait for user input, it's not present by default on WinXP, so executing it will only return an error message saying ""CHOICE" is not recognized bla bla bla"...
Here's a sample of batch menu on NT batch scripting:
@echo off
echo Choose:
echo [A] Option 1
echo [B] Option 2
echo.
:choice
SET /P C=[A,B]?
for %%? in (A B) do if /I "%C%"=="%%?" goto ok
goto choice
:ok
echo C=%C%It's still a good idea to post your batch.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

Here it is:
@echo off
goto menu:menu
echo.
echo What would you like to do?
echo.
echo Choice
echo.
echo 1 Open Softphone
echo 2 Open Internet Explorer
echo 3 Open Mailout
echo 4 Open Lantern
echo 5 Open Notepad
echo 6 Open Netscape
echo 7 Quit
echo.pause
choice /C:1234567 /n Your Choice:
if errorlevel 7 goto quit
if errorlevel 6 goto net
if errorlevel 5 goto note
if errorlevel 4 goto lan
if errorlevel 3 goto mail
if errorlevel 2 goto ie
if errorlevel 1 goto soft:soft
start C:\Progra~1\
goto menu:ie
start iexplore.exe http://www.google.ca/
goto menu
start h:\mailouts2.html
goto menu:lan
start iexplore.exe http://
goto menu:note
start notepad
goto menu:net
start netscape -mail -P"netscape"
goto menu:quit
exit
:end

Are you sure that script pops up thw window and close immediately? The PAUSE command should prevent that...
Anyway, if CHOICE.COM is not present (and it's not present by default), the script won't work. Try this one:
===== BATCH SCRIPT BEGIN =====
@echo off
goto menu
:menu
echo.
echo What would you like to do?
echo.
echo Choice
echo.
echo 1 Open Softphone
echo 2 Open Internet Explorer
echo 3 Open Mailout
echo 4 Open Lantern
echo 5 Open Notepad
echo 6 Open Netscape
echo 7 Quit
echo.:choice
set /P C=[1,2,3,4,5,6,7]?
if "%C%"=="7" goto quit
if "%C%"=="6" goto net
if "%C%"=="5" goto note
if "%C%"=="4" goto lan
if "%C%"=="3" goto mail
if "%C%"=="2" goto ie
if "%C%"=="1" goto soft
goto choice:soft
start C:\Progra~1\
goto menu:ie
start iexplore.exe http://www.google.ca/
goto menu
start h:\mailouts2.html
goto menu:lan
start iexplore.exe http://
goto menu:note
start notepad
goto menu:net
start netscape -mail -P"netscape"
goto menu:quit
exit
:end
===== BATCH SCRIPT END =====-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

Thanks man, that really helps alot. Yeah, the pause command did stop it from closing, I put it there just for that because I wanted to see what the menu looked like, but if it wasn't there, it would close.
The only thing is, when i press a number, nothing happens???
Any way, thanks anyway, I'll try and figure it out, if you have any ideas, I'm all ears

You gotta enter the number and press enter. Perhaps it would be good to inform user that such action is required.
If you need something more close to CHOICE.COM, see the following subject:
http://www.computing.net/dos/wwwboard/forum/11117.htmlNevertheless, I prefer this method which I posted here.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |