VOGONS

Common searches


First post, by Sephiroth

User metadata
Rank Member
Rank
Member

I've been working on a front-end that will mount a specified directory as C: in DOSBox, and run games from that directory. This part works flawlessly, and DOSBox 0.72 does an excellent job emulating the CPU and soundcards, but there is one minor problem that I am running into that is stumping me. When my front-end generates the DOSBox configuration for any selected game, it adds lines to the autoexec section to mount the specified directory, change to the game directory, start the game, and then exit. The problem is that while it starts the games and runs them beautifully, it never executes the "exit" command when you quit the game! The "-exit" command-line parameter won't work in this manner either.

Before it is recommended that I use "DOSBox C:\MyGame\MyGame.exe -conf whatever.conf -exit" to run the game, this won't work because unless I am mistaken, it would mount "C:\MyGame" as C:, which screws with games like Daggerfall. These games require the game to be in "C:\Game\game.exe", not the root of the drive. This is why I have to mount a specified folder where the games are installed as C:, and is why as far as I know, I cannot use the command-line method of launching games.

So, how can I make DOSBox exit once a game has exited and control returns to the OS? In real DOS, you could do this kind of thing with the autoexec.bat file, such as calling reboot.com to restart the computer after a game exits, maybe to return to a menu of games or Windows.

486 Launcher v2.0 is now under development!

Reply 1 of 14, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

add exit to the autoexec.bat

and it is not a bug. Please read the description -exit as commandline parameter in the readme.

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

Reply 2 of 14, by Sephiroth

User metadata
Rank Member
Rank
Member

How would I add it to the autoexec.bat file? I have it in the autoexec section in dosbox.conf. In fact, here is a copy of the last one I tried.

[autoexec]
mount C: ..\System
C:
cd C:\Dagger
dag.bat
exit

Everything executed, but once I quit playing, it left me in a fullscreen DOSBox window instead of executing the line with "exit" on it.

486 Launcher v2.0 is now under development!

Reply 4 of 14, by Sephiroth

User metadata
Rank Member
Rank
Member

Ah I hadn't thought of trying to use call. Will try it and if I don't report back here, it works and I thank you. However, would I need to call exe and com files as well?

486 Launcher v2.0 is now under development!

Reply 5 of 14, by DosFreak

User metadata
Rank l33t++
Rank
l33t++

CALL is included inside the command inerpreter, it's not a seperate executable.

Last edited by DosFreak on 2008-06-12, 18:28. Edited 1 time in total.

How To Ask Questions The Smart Way
Make your games work offline

Reply 7 of 14, by Qbix

User metadata
Rank DOSBox Author
Rank
DOSBox Author

this is btw not dosbox specific. "real" dos behaves the same with batch files and call

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

Reply 8 of 14, by Sephiroth

User metadata
Rank Member
Rank
Member

Really? I just tried placing a batch file that would echo "Inside batch file" to the screen and return and a line right below it in the autoexec.bat file that echoed "Outside the batch file" and then pause. Upon booting the machine I got both messages without using "call". I know all about call but have never had to use it before. I tested that batch file on a 486SX using DOS 6.22 and on a P2/233 using the DOS counterpart that comes with 98SE. Both worked without using call.

Test.bat:

echo off
echo Inside the batch file!

Autoexec.bat:

test.bat
echo Outside the batch file!
pause

Works fine on both machines. Is this something that was needed back in DOS5? I used DOS5 with DOSShell on an 8086, but I didn't know batch-scripting back then and never used it.

486 Launcher v2.0 is now under development!

Reply 10 of 14, by DosFreak

User metadata
Rank l33t++
Rank
l33t++
[autoexec]
mount C: ..\System
C:
cd C:\Dagger
dag.bat
exit

Whyt not put "exit" in dag.bat or put the content of dag.bat in the [autoexec] section?

How To Ask Questions The Smart Way
Make your games work offline

Reply 11 of 14, by Sephiroth

User metadata
Rank Member
Rank
Member

I don't put it in the batch file because many older games came with pre-made batch files, such as Railroad Tycoon. Now if your average user grabs my front-end and selects the batch file and then starts the game up, he or she won't know why the game isn't exiting back to Windows when they're done playing. I want to make this program as idiot-proof and as user-friendly as possible.

It works now anyway, and that is all that matters. I don't know why this is working for me on my older DOS systems and not in DOSBox or for wd. I have multiple systems to test this on dating back to a 286, but it isn't that important. Use call for batch files in DOSBox, that's all a user needs to know when looking over this thread.

However, should I use call when starting an exe or com program, or just with batch files? I want games that use compiled program files to exit when done also, but if call isn't needed, I'll scan for .exe and .com and not plop it in the autoexec if those are found.

486 Launcher v2.0 is now under development!

Reply 12 of 14, by ripsaw8080

User metadata
Rank DOSBox Author
Rank
DOSBox Author

I'll say it again, since you ask again: the call command only applies when running one batch file from another; it is not used with executables.

Without CALL, you are transfering control to the other batch file, never to return. I can not explain how you are getting CALL behavior without using the command... it would mean your DOS is not behaving in a DOS-compatible way. 😒

Reply 13 of 14, by wd

User metadata
Rank DOSBox Author
Rank
DOSBox Author

it would mean your DOS is not behaving in a DOS-compatible way

I can second that (maybe using some command.com replacement or so).
The behaviour of batch file calling is documented ever since, and did
really behave like that (if you look at more complex .bat file systems you'll
see a lot of CALLs to other batch files for that reason).

Reply 14 of 14, by Sephiroth

User metadata
Rank Member
Rank
Member

Odd, must have to do with those complex configs I did so I'd get a boot menu when starting the old machines up. Somewhere along the way I did something that caused this. Once I get my new place and have room to setup all my machines, I'll figure it out and post my findings.

Thanks for the help though, my program is working wonderfully with DOSBox now.

486 Launcher v2.0 is now under development!