VOGONS


First post, by WhiteKenny

User metadata
Rank Newbie
Rank
Newbie

I'm sorry if this has been posted in the past but I was unable to find any other posts about this issue when I searched. I'm trying to create a menu within a batch file to run some old DOS games. the menu seems to work, but no matter which option I select it always launches the 1st game. any help would be appreciated.

here is the batch file I've created.

ECHO OFF
CLS
:MENU
ECHO.
ECHO ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»
ECHO º Shall we play a game. º
ECHO ÌÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ͹
ECHO º º
ECHO º 1 - Wolfenstein 3D º
ECHO º 2 - The Ultimate Doom º
ECHO º 3 - Evilution º
ECHO º 4 - The Plutonia Experiment º
ECHO º º
ECHO ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ
ECHO.
ECHO Type 1, 2, 3 or 4 to start the game:
CHOICE /C:1234 /N
IF ERRORLEVEL=1 GOTO WOLF3D
IF ERRORLEVEL=2 GOTO DOOMSE
IF ERRORLEVEL=3 GOTO TNT
IF ERRORLEVEL=4 GOTO PLUTONIA

:WOLF3D
cd WOLF3D
WOLF3D.EXE
CD..
GOTO MENU

:DOOMSE
cd DOOM_SE
DOOM.EXE
CD..
GOTO MENU

:TNT
cd TNT
DOOM2.EXE
CD..
GOTO MENU

:PLUTONIA
cd PLUTONIA
DOOM2.EXE
CD..
GOTO MENU

Reply 1 of 8, by 2fort5r

User metadata
Rank Member
Rank
Member

It's been a long time but I think you have to test them in the reverse order, so 4 first, 3 next and 1 last.

I think ERRORLEVEL=1 actually means ERRORLEVEL>=1 so it will be valid for all values

Account retired. Now posting as Errius.

Reply 4 of 8, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

The "level" in ERRORLEVEL almost makes the behavior self-explanatory. Almost. 😉

Using an equal sign (=) is superfluous in the MS-DOS syntax, it ends up being nothing more than a separator, and implies a test that is not actually performed. So, if only for the sake of clarity, it's better to just use a space for the separator.

Reply 6 of 8, by WhiteKenny

User metadata
Rank Newbie
Rank
Newbie

hey, thanks everybody, I removed the ='s and reversed the order of the ERRORLEVEL entries and it's working now. my only other question would be, I have it set so that the menu reloads after exiting any of the games so is there any way I can add an option in the menu that will exit the menu back to a DOS prompt? I've tried just manually pressing CTRL+C but that doesn't seem to be doing anything.

Reply 7 of 8, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

add

:hi

at the bottom of your menu batchfile and make an item (with the correct error level)

goto hi

Water flows down the stream
How to ask questions the smart way!

Reply 8 of 8, by WhiteKenny

User metadata
Rank Newbie
Rank
Newbie
Qbix wrote:
add […]
Show full quote

add

:hi

at the bottom of your menu batchfile and make an item (with the correct error level)

goto hi

that worked perfectly, thanks so much everybody. i promise i'll stop bugging you now...