Moving User Data to the game folder

@AndreasFSC @mucho may be interested

I am trying to move Userdata to the local folder.
Why?
Older version of Race 07 and earlier games had Userdata in the game folder.
The files could be accessed, read, created and modified using relative paths.

First, I copied config.ini to devfiles folder, because it can be deleted by the game.

I have tested some config files in batch

I wrote a short .cmd file
Code:
@echo off
copy devfiles\config.ini .
(dot = here)
Code:
echo Running Config
config.exe
echo Running the Game
Race_Steam.exe
copy devfiles\config.ini .
(once again for the next init)
Code:
exit /b

After exit from config, the game should start.

I tested config files for
RFactor, GTR2, Race07 early, STCC1, BMW M3 Challenge.
These are games where the Userdata folder is a subfolder of the game.
Running config.exe don't create user files neither in documents nor in local folders... and the game doesn't start in batch.
The user folder in documents is created by the game .exe file.
The game must be started manually, then the settings are copied to documents from config.ini

STCC 2 config is the first one that creates User folder in documents by itself.
The game starts in batch.
The only disadvantage is that the track maps in game are blue (it doesn't support skins).

Volvo config is the only that creates a folder with the Application info name.
The game starts automatically in batch.
and it also creates one more folder, Race 07 install ##
So we have two remote folders, instead of one, it is worse.

RaceRemaster config is from Volvo the Game. The files differ only by text GameinstallDir replaced with GameinstallOrg to differentiate the original user files from the Remaster files.

Back to the original GTR Evo config.

Remember to delete the user folder from documents every time the .cmd is started.

line 6061 - change:
Code:
SimBin\RACE 07
to
Code:
Userdata\ABCDE
(five random chars)

and the first occurrence in this line of
Code:
GameinstallDir=0
(binary zero, NUL)
to
Code:
GameinstallDir=.

Remote folder is no longer created by config, but it is created by the starting game, still in Documents\SimBin\Race 07 install ##.

We find the same sequence in the game .exe in line 21509
Replace the same chars and save as a new file.
If we edit .exe in Notepad++, it must be saved as "All types", not any other text document.

Successful, UserData folder has been created in
Code:
Documents\UserData\ABCDE
not in
Code:
Documents\SimBin\Race 07 install ##

The goal is to create it in game folders, to access the files by relative links.

One more try. Replace in both files (config.exe and game .exe)
Code:
\Userdata\ABCDE
with
Code:
.\UserdataABCDE
(the same length)

User folder named UserdataABCDE
is still created by config in documents
but without a subfolder.
The starting game adds files to this folder.

Better.

Now a question.
Can we share the same user folder for all installs of Race 07?
Copying:
config.exe config.ini game.exe and the .cmd file
to another installed R07.
Will a number be added?

This time not deleting the user folder from documents.

Unfortunately, the number has been added
the new folder is
Code:
Documents\UserdataABCDE install 2

Deleting both user folders.

Now we have two ways.
Get rid of the numbers, use one folder for all installs
or
Try to move userdata out of Documents.

change to
Code:
UserdataABCDEFG
created the folder in the root of the drive, where Documents are located
Folder name is preceeded by Documents folder name
Code:
DocumentsUserDataABCDEFG
Worse.

System variables... will it understand?
replacing
Code:
UserDataABCDEFG
with
Code:
%__CD__%\UserAB
Fail.
%__CD__% that means "current directory" should create a folder UserAB in the game folder, where we want.
But no, it was interpreted as plain text, and created a folder UserAB in the folder named:
Code:
Documents%__CD__%

Reverting to the safest
Code:
.\Userdata\User
The Userdata folder is created in Documents\Userdata\User

The first change to
Code:
GameinstallDir=.
did nothing, because the current folder was changed to Documents before.
Before creating the user folder, the exe somewhere does
Code:
cd documents
If the current folder was not changed before, the Userdata folder would be created in the same location as the game.

Not this way. I have to find how the game obtains the location of documents and replace it with current folder.

Be careful with these .\ and ..\
Some constructions may create undeletable folders.

The game code uses variables, but how to use them?
Variables are defined only as types %s = string %d = decimal and other types,
but where are the initial values?

Some values are read from .ini files. Other values are modified from game menu, but we are talking about the very init of the game, before the menu starts.

Pause for today....
This is the interesting part in config.exe, the same sequence is repeated in game exe.
config_race07_20221028.png
 
Volvo config is the only that creates a folder with the Application info name.
The game starts automatically in batch.
and it also creates one more folder, Race 07 install ##
So we have two remote folders, instead of one, it is worse.

RaceRemaster config is from Volvo the Game. The files differ only by text GameinstallDir replaced with GameinstallOrg to differentiate the original user files from the Remaster files.

Yes ApplicationInfo.gdb is used, so the game could be named anything ApplicationTitle=RACE 07

First I called the game 'Race R', but I wanted to use the same userdata files after I changed the installation process to change between 'modes' in one game, so I changed it back.
The game or setup file will create a new folder ie. 'Install 2' if there is no gameinstalldir ini file with the 'right' folder.
 
When the game starts it automatically overwrites some values in the plr file resetting them to defaults. It just seems that your understanding of the exe file (I have no clue) you may know if the overwriting process could be removed.
 
  • Deleted member 13397

i am not sure if this stil a open question :

the new number is created if the GameInstallDir entry does not equal the path the EXE file is located
 
  • Deleted member 13397

a solution could be, add to the companian a patch, which forces to update the path in game memory to desired place , but lacking motivation doing so
 
When the game starts it automatically overwrites some values in the plr file resetting them to defaults. It just seems that your understanding of the exe file (I have no clue) you may know if the overwriting process could be removed.
There are a lot of functions in the game that tests the game settings in the player file and changes them if they are out of a predefined range. It is probably a similar thing going on here.
 
The player .plr file is in the remote folder (in documents).
If we move UserData to the game folder, all files will be accessible, the player file, the championships. They could be copied to a temporary folder and restored when needed.

We cannot load a championship when we already finished it, to play again.
If we delete racing stats, we can load it and play again with the same settings and cars.
 
  • Deleted member 13397

made some test, cant be done threw companian
the EXE gets the path and imediatly starts scanning for stuff like Setups


so only two ways, EDITING or PATCHING THE EXE
so it does not ask for USER ENVIRENT PATH
 
Last edited by a moderator:
  • Deleted member 13397

here a poor mans solution

1. copy your SIMBIM documents from USERDATA to your RACE07 directory
c:\Users\__________________\Documents\SimBin\
to
f:\RACE07\SIMBIN

2. set USER DIR ENV in REGs

reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Personal /d "f:\race07" /f

3.
start the game

4.
set the ENV variable back to normal

reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Personal /d %USERPROFILE%\Documents /f



this solution works, but it has its drawbacks
you may start this in a batch file
and
you may now chage in the EXE the exact Directory name (so remove the SIMBIN)


p.s.: reg needs to be started in command line, dont know if you need admin rights and only tested on WinX_64
 
Last edited by a moderator:
My %userprofile%\documents is empty. The Documents folder is on D:\DATA.
The starting game immediately finds where the documents folder is located.
There are too many maybes...
maybe it reads it from registry
maybe it's in a .dll file, not in .exe
Even if I change the path to
Code:
..\..\GameName
the user folder is created outside documents, but still relative to documents.

Temporarily I leave it as
\GameName\
so the folder GameName is created in documents, but not in SimBin folder.

The routine may be here, but these are just a list of commands, not a program sequence.
It may be called from the code somewhere else in the config file.
2022-11-10.png
 
Last edited:
  • Deleted member 13397

the solution stated above works
it is not perfect, but it works on modern windows systems

if your documents folder is in d:\data
then change in step 4 the path to d:\data
 
I think about all users, everyone who runs the game.
The game may be on any drive and documents location may be anywhere too.
The goal is not to move files back from documents to the game folder, just to find where the config reads the documents path and replace it with the game folder.
I think I must compare these lines with the older games, that create user data in the game folder.

Will it work if I change in the registry add from
Code:
reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v 
Personal /d "f:\race07" /f
to
Code:
reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v 
Personal /d . /f
dot (here) instead of absolute path to the game,
or %__cd__% current folder
The command is executed from the game main folder.
 
Last edited:
  • Deleted member 13397

Unfortunatly this does not work at my computer

but this does

reg add "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Personal /d "%CD%" /f

still you need to have one RACE07 INSTALL directory in SIMBIN structure containing a file GameInstallDir.ini with the real PATH



p.s.: with this command you can check the current value of the registry:
reg query "HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Personal
 
Last edited by a moderator:
  • Deleted member 13397

and
this is not the solution you are looking for, for a solution compatible with other games you need to change the RACE EXE


over and out
 
Back
Top