Steam on Linux: Run Windows Apps inside Games' Wine Prefix

I have stumbled on a problem when running Dungeon Siege II on Linux (Ubuntu), I’m trying to run the game via Steam and in order unlock Broken World extension there is a .bat file that must be executed.

Running the script directly using wine doesn’t work because Steam stores it’s configuration somewhat hidden behind WINEPREFIX.

It turns out that the trick is to set up WINEPREFIX correctly before running anything, like that:

$ WINEPREFIX="/home/$USER/.steam/debian-installation/steamapps/compatdata/$GAMEID/pfx" wine <script>

In case of Dungeon Siege II the command looks like that:

$ WINEPREFIX="/home/$USER/.steam/debian-installation/steamapps/compatdata/39200/pfx" wine RegPatch\ DS\ II.bat

You can find out the GAMEID by either inspecting the contents of the compatdata directory or checking steam_appid.txt file inside the game’s installation directory.