How I made Windows ScummVM portable

Discussion about other and unofficial ports of ScummVM

Moderator: ScummVM Team

Post Reply
Posts: 3
Joined: Wed May 04, 2016 9:02 am

How I made Windows ScummVM portable

Post by LegendforHire » Thu May 05, 2016 9:39 am

Hi all. I'm fairly new to ScummVM and I'm really getting into it.

After doing a lot of forum browsing I learned that ScummVM is, in essence, portable, but there are prohibitive factors. I wanted to get over those factors

This topic was quite informative and gave me a good place to start. I thought about posting this in that topic, but didn't think reviving such an old topic would be good form so decided to create a new one.

Here are the significant prohibitive factors referred to, preventing ScummVM from being truly portable...
  • 1. scummvm.ini is stored in the main Windows folder. If a USB stored instance of ScummVM is run on a new computer, then ScummVM will just create a new, blank .ini file in that computer's Windows folder. Previously saved settings will not be applied in this case. (This is easily overcome)
    2. All of the game paths stored in scummvm.ini are absolute and relative to the machine that applied them. So if a game is added to Computer A where the USB drive might be D:\ it might be referenced in scummvm.ini as D:\scummvm\gamefiles\fotaq\ for example. But if then, when using Computer B, which might have assigned a different drive letter (eg E:\) to the USB then scummvm will be looking in the wrong place and won't find the game. These references need to be made relative rather than absolute with minimum effort.
So here's how I solved it...

It's worth noting at this point that all my games are in a subfolder of ScummVM called \Gamefiles\ (It's important that this subfolder is uniquely named and must not have the same name as any parent folder in the path). Every game I added to ScummVM was added from this location.
Also, my Saved games are also saved in a subfolder of ScummVM called \Saved games\.
  • 1. Move scummvm.ini from the windows folder to the ScummVM folder, the same folder where the scummvm.exe is stored and run from.
    2. Make a backup of it. I copied it and renamed the copy scummvm.ini.old
    3. Edit the scummvm.ini file and changed the line that begins savepath= to savepath=.\Saved games\. (the .\ means the path is a subfolder relative of the folder ScummVM is run from.
    4. Create a new text document called scummvm.bat.
    5. Edit scummvm.bat using a text editor such as notepad or, better still notepad++. Fill it with the following and save it.

    Code: Select all

    @echo off
    setlocal enabledelayedexpansion
    REM Put your preferred SDL environment variable settings here
    REM *************************************************************************************
    REM Set your variables
    	REM ScummVM's INI file
    	set vIniFile=scummvm.ini
    	REM Temporary file used by the script (must not already exist as this will be deleted)
    	set vTempFile=TempOut.1234
    REM *************************************************************************************
    REM  This section ensures that all fixed game paths become relative.
    REM  This ensures that the game is portable.  As long as all Games are
    REM  stored in the \Gamefiles\ subfolder within the main ScummVM folder
    REM  and ScummVM is executed from this script.
    	(for /f "tokens=*" %%a in (%vIniFile%) do (
    		set "line=%%a"  
    		if /i "!line:~0,5!"=="Path=" set "line=Path=!line:*\Gamefiles=.\Gamefiles!"
    		echo !line!
    		del /f %vIniFile%
    		ren %vTempFile% %vIniFile%
    REM  Run ScummVM.exe using the new INI file.
    	scummvm.exe -c %vIniFile%
So now when I run my new scummvm.bat it will check through scummvm.ini line by line and copy each line to a new temporary file. But whenever it comes across a line beginning with Path= it will replace everything from between Path=and \Gamefiles with .\. So for example, Path=D:\ScummVM\Gamefiles\fotaq\ will become Path=.\Gamefiles\fotaq\.
When the end of the ini file is reached, it will delete scummvm.ini and rename the temporary file to become the new scummvm.ini.
Last of all, it executes scummvm.exe with a parameter instruction to use the local scummvm.ini instead of looking in the Windows folder for it.

There you have it. What do you think? I'm sure it can be improved, comment below if you have any ideas.

Post Reply