I'm stuck with my .bat that doesn't execute correctly if any mistakes please report it
File name - games.bat
@echo off
G:
:start
cls
echo DOS Games
echo 1. DOOMS
echo 2. Prince of Persia
set /p choice=Your Choice is
pause
if %choice% == 1 goto 1
if %choice% == 2 goto 2
if %choice% == %choice% goto start
:1
cd PRINCE~1
PRINCE.EXE
exit
:2
cd DOOMS
DOOM.EXE
exit
I just want to run the games by selecting their numbers
I'm running the .bat in DOSBOX which may not be compatible with windows bat syntax
Also any other suggestions are ok to me
I'm tierd of writing new config files and shell scripts again and again for many games so I decided to write a .bat code which can run on DOSBOX and load games one by one
CodePudding user response:
The choice command is available for dosbox and probably the only way to achieve what you want:
mount G .
G:
:start
rem --- descriptions ---
choice /c12 /s Your Choice is [1-2]: /n
if errorlevel 2 goto two
if errorlevel 1 goto one
goto start
:one
cd PRINCE~1
PRINCE.EXE
exit
:two
cd DOOMS
DOOM.EXE
exit
You can check the the chosen option with if errorlevel
but mind that errorlevel works like equal or bigger than..
and you should start with the bigger numbers first. You can check the result only with IF ERRORLEVEL
as %ERRORLEVEL%
variable is not accessible and you cannot use the three letter comparison operators under dosbox.
The other thing I've noticed is that there's no mapping of a device. To have access to your files under dosbox you need to mount a certain directory as a drive first. Here I've mounted G: as the current directory.(or may be it is mounted in the conf file?)