Writing .bat files to automatically run games in DOSBox?

Discuss coding, porting and creating games
Post Reply
Grunge_Rocker
Less than a nibble
Posts: 3
Joined: June 14th, 2009, 6:25 pm

Writing .bat files to automatically run games in DOSBox?

Post by Grunge_Rocker »

I am a little rough around the edges on my programming, I mostly work with Visual Basic doing things like writing Webbrowsing programs, and I very seldom detour away to things like writing simple .bat files.

That's why I need someone to show me how to write a .BATch file that will:

1) Open DOSBox (this much has been accomplished)
2) Pass commands to the DOSBox prompt (Bypassing Windows-native MS-DOS command prompt) that tells DOSBox to automatically mount a directory and run a desired program.

IOW when finished, I want to be able to click on my "Wolf3D.bat" file and automatically play Wolfenstein 3D by having DOSBox come up and run it for me.

In this fashion, I plan to take out all the efforts of opening DOSBox and then manually mounting the directory myself, then pointing to the desired program and telling DOSBox to run it, as this newly created .bat file would take care of all that for me. It would automatically begin emulating the program once loaded.

Anybody care to take stab?
User avatar
Qbix
DOSBox Programmer
Posts: 45
Joined: October 31st, 2007, 7:43 am

Re: Writing .bat files to automatically run games in DOSBox?

Post by Qbix »

maybe check the readme of DOSBox
it lists a lot of commandline options for DOSBox which can be used to start games.
Grunge_Rocker
Less than a nibble
Posts: 3
Joined: June 14th, 2009, 6:25 pm

Re: Writing .bat files to automatically run games in DOSBox?

Post by Grunge_Rocker »

It sure is a start!
Grunge_Rocker
Less than a nibble
Posts: 3
Joined: June 14th, 2009, 6:25 pm

Re: Writing .bat files to automatically run games in DOSBox?

Post by Grunge_Rocker »

Problem solved. I read the documentation. Many thanks!

The contents of my .bat file reads as such:


CD C:\Program Files\DOSBox-0.72
dosbox c:\INTRPLAY\Redneck\rr.exe

Those two lines are all that is in my .bat file to automatically load and play the game Redneck Rampage. For me, it works like a charm. I may write up a side-program to help DOSBox users to easily make .bat files to instantly start up their old games in DOSBox without any hassles.
User avatar
Qbix
DOSBox Programmer
Posts: 45
Joined: October 31st, 2007, 7:43 am

Re: Writing .bat files to automatically run games in DOSBox?

Post by Qbix »

Code: Select all

CD C:\Program Files\DOSBox-0.72
dosbox c:\INTRPLAY\Redneck\rr.exe  -exit
Will be even prettier.
blinkingboythe
5-bit member
Posts: 36
Joined: August 13th, 2013, 1:09 am

Re: Writing .bat files to automatically run games in DOSBox?

Post by blinkingboythe »

copy the dosbox.conf file to startup.con

add this to the autoexec area (at the end) of startup.con


rem replace "dosgames" with whatever folder your dos games are in
mount c c:\dosgames
mount d c:\bat
c:
call d:\begin.bat
exit


Make a a folder in c:\ called bat

next, write this batch file (call it db.bat)

@echo off
echo cd %1>c:\bat\begin.bat
echo. %2 %3 %4 %5 %6 %7 %8 %9>>c:\bat\begin.bat
:: replace next line to whatever folder dosbox is in.
cd \dosbox
dosbox -conf startup.con

Here's the usage:

db (folder name of dos game) (executable name)
User avatar
MrFlibble
Forum Administrator
Posts: 1798
Joined: December 9th, 2010, 7:19 am

Re: Writing .bat files to automatically run games in DOSBox?

Post by MrFlibble »

I'm not quite sure there's a need for batch files to run separate games if each of them uses its own DOSBox configuration file. Wouldn't it be much simpler to just put all the lines into the [autoexec] section of the respective configuration file? That way, one can create desktop shortcuts for each game that point to the respective configuration files.
blinkingboythe
5-bit member
Posts: 36
Joined: August 13th, 2013, 1:09 am

Re: Writing .bat files to automatically run games in DOSBox?

Post by blinkingboythe »

This is mostly a proof of concept on how to send commands directly into Dosbox from the Windows command prompt. Most of my dos games use the same configuration so I use this method at the command prompt and in my shortcuts. I have a more complicated version of what I posted here that includes time and date logging to a file.
User avatar
MrFlibble
Forum Administrator
Posts: 1798
Joined: December 9th, 2010, 7:19 am

Re: Writing .bat files to automatically run games in DOSBox?

Post by MrFlibble »

Hmm, quite some time ago I used to launch games in DOSBox from Windows shortcuts, with all necessary commands (mount disks, use configuration file, exit on programme end etc.) typed in a shortcut's command line section. Then I figured out I could type all that inside an individual conf file just the same (except it's easier to edit a conf file than a shortcut's properties IMO).
Post Reply