VOGONS

Common searches


First post, by Wilfred

User metadata
Rank Newbie
Rank
Newbie

Hi!

Here is a batch (.bat) file I created to make DOSBox games portable in Windows. I also posted it on the Good Old Games forum.

The batch file uses a variable based on the location of the batch file to recreate the directory path relative to the batch file.

The DOSBox directory and game directories must be subdirectories of the batch file directory so that the locations of the DOSBOX directory and game directories remain fixed in relation to the batch file.

In this file, DOSBox.exe is in \DOSBOX and the game executable is in \GameDir. Edit as needed.

Benefits:
Once it is set up, this batch file greatly simplifies the process of running a DOSBox based game.
- No more having to create / edit a shortcut or batch file to get your game running properly every time you reinstall or make a change to your game.
- No more typing long command strings to load a DOSBox game with your preferred settings.
- No more having to run the install file to reinstall. Just set up all your preferred settings and make a backup copy. Then you can move / restore your game anywhere without loosing your preferred settings.
- Always only one click needed to load your game with proper settings! The directory containing the batch file, DOSBox, and game(s) can be moved anywhere and the game(s) will still run by clicking the batch file.

Pre Setup:
- Verify that the settings in your game's DOSBox configuration .conf file are correct.
- Verify that DOSBox loads / runs your game correctly with no crashes or errors.
- Create a game folder / directory with subdirectories containing the DOSBox files and game files.
- Copy the game's DOSBox configuration .conf file to the \DOSBOX subdirectory.

Setup:
- Open a new text file in Notepad.
- Copy the batch file text into the new file.
- Change the subdirectory, .exe, and .conf names to match your subdirectory structure and file names.
- Save the batch file in the game directory with the game's name and a .bat file extension.
- Click the batch file to run the game!
- Optional: Create a shortcut from the batch file to the start menu / taskbar / desktop, rename the shortcut as needed, and change the shortcut icon to the game icon.

I'm using Windows XP, but this should work in Windows 7 also. Please post confirmation or issues. - Thanks!

---------- begin batch file ----------
::
:: Double colon denotes a remark.
::
:: @ = Do not echo back the text after the "@" symbol.
:: ECHO displays messages.
:: ECHO OFF turns command-echoing off.
:: So @ECHO OFF prevents any of the commands
:: in the batch file from being displayed.
::
@ECHO OFF
::
:: CLS is the DOS command to clear your screen.
::
CLS
::
::
:: The command SET stores a variable.
:: % (percent) = a variable
:: ~ (tilde) = a variable modifier
:: d = Drive letter
:: p = Path
:: Variable 0 (zero) in a batch file is always SET to the batch file name.
:: So variable %~dp0 is the drive and path where the batch file resides.
::
::
:: DOSBox Command Line Parameters:
:: [dosbox.exe] [name] [-exit] [-conf congfigfilelocation] [-noconsole]
::
:: [name] If "name" is an executable it will mount the directory
:: of "name" as the C: drive and execute "name".
::
:: [-exit] DOSBox will close itself when the DOS application "name" ends.
::
:: [-conf congfigfilelocation] Start DOSBox with the options specified
:: in "configfilelocation". Multiple -conf options may be present.
::
:: [-noconsole] (Windows Only) Start DOSBox without
:: showing DOSBox Status Window (console).
:: Output will be redirected to stdout.txt and stderr.txt
::
::
:: START starts a program or command in a new window.
::
:: START "title" [/D"path"] "command" [parameters]
::
:: "title" = title to display in window title bar.
:: Always include the title.
:: The title can be just a pair of empty quotes: ""
::
:: "path" = starting directory that the
:: command is being executed from.
::
:: DOSBox.exe should be executed from the
:: \DOSBOX directory so that the DOSBox log files
:: will be saved to the \DOSBOX directory.
::
START "" /D"%~dp0\DOSBOX" "DOSBox.exe" "%~dp0\GameDir\game.exe" -exit -conf "%~dp0\DOSBOX\DOSBoxGameConfigFile.conf" -noconsole
::
::
:: Using the START command instead of directly
:: executing DOSBox.exe allows this batch file to
:: EXIT immediately instead of when DOSBox closes.
::
EXIT
::
---------- end batch file ----------

----- EDIT -----

More Benefits:
- You can launch your games from a flash drive!
- No [autoexec] section needed in the .conf file.

A few more examples:

The code below is the same as the example above without comments. This code assumes that the batch file is in the parent directory and the .conf file is in the DOSBOX directory.

---------- begin batch file ----------
@ECHO OFF
CLS
START "" /D"%~dp0\DOSBOX" "DOSBox.exe" "%~dp0\GameDir\game.exe" -exit -conf "%~dp0\DOSBOX\DOSBoxGameConfigFile.conf" -noconsole
EXIT
---------- end batch file ----------

The code below assumes that the batch file is in the parent directory and the .conf file is in the game directory.

---------- begin batch file ----------
@ECHO OFF
CLS
START "" /D"%~dp0\DOSBOX" "DOSBox.exe" "%~dp0\GameDir\game.exe" -exit -conf "%~dp0\GameDir\DOSBoxGameConfigFile.conf" -noconsole
EXIT
---------- end batch file ----------

The code below assumes that both the batch file and the .conf file are in the game directory.

CD = the Change Directory command
%cd% = a variable which expands to the current directory string

---------- begin batch file ----------
@ECHO OFF
CLS
CD ..
START "" /D"%cd%\DOSBOX" "DOSBox.exe" "%~dp0\game.exe" -exit -conf "%~dp0\DOSBoxGameConfigFile.conf" -noconsole
EXIT
---------- end batch file ----------

Last edited by Wilfred on 2013-04-06, 10:48. Edited 1 time in total.

Reply 1 of 3, by Mau1wurf1977

User metadata
Rank l33t++
Rank
l33t++

Another way is using D-Fend reloaded. It can be installed in Portable mode onto a USB storage device for example.

My website with reviews, demos, drivers, tutorials and more...
My YouTube channel

Reply 3 of 3, by leileilol

User metadata
Rank l33t++
Rank
l33t++

If I ever wanted it "portable", all i'd do is put this at the very end of dosbox.conf.........

mount C: ".\dos\"

No need for fishy "PORTABLE APPS DAWT CAWM!!1!" versions. With this setup you could even start up a dos frontend for the games like rcblanke's Access or enthusiast favorite QuikMenu III

Also DBGL can work with relative paths.

apsosig.png
long live PCem