You'll have to forgive me (or not) my knowledge of batch programming is fairly rudimentary.
I have created a couple of batch files to help launch a game, change a system variable (to move saved games inside the game folder) basically make it portable.
It works when it resides within folders with no spaces in the path. However when put in say, Program Files (x86) it falls over.
Here is the code I am using to obtain the relative parent path.
for %%B in (%~dp0\.) do set APPPATH=%%~dpB
This is the important part, everything else in the script relies on this.
Here is the rest:
: Get path of parent folder (relative)
for %%B in (%~dp0\.) do set APPPATH=%%~dpB
set APPPATH2=%APPPATH%Microsoft Games\Freelancer\
: Modify path of Freelancer in the registry to point to the portable install
REG ADD "HKLM\SOFTWARE\Wow6432Node\Microsoft\Microsoft Games\Freelancer\1.0" /v AppPath /t REG_SZ /d "%APPPATH2%\" /f
: Set path for Saved Games
Set USERPROFILE=%APPPATH%
: Start Freelancer up
START "" "%APPPATH%Microsoft Games\Freelancer\EXE\Freelancer.exe"
Is it possible for this code to be modified to be able to handle spaces in the scripting? I have managed to set up my template so it doesn't effect anything else, but this part of the path is where it is falling down.
I use the APPPATH variable to output a full path relative to whereever the file is on a computer.
Thanks for the help!
::
your single colon works but isn't quite what you think it is You have actually created labels. So you could make a goto to a label you created! To prove it, try running this batch file pastebin.com/raw.php?i=cJ0P7JSC