I have a game that uses this file structure:
GAME FOLDER
->data
->data->run.bat
I want to put a shortcut to run.bat
i
I'm not sure if I'm right, or I'm missing something, but as for now (2016-07-11, running Win7 Enterprise SP1) a LNK file adapts itself on moving or even changing the drive letter after it is run at a new place! I created a new shortcut on my USB drive and tried moving the shortcut and its target in a way that the relative position stayed unchanged, then I changed the drive letter. The shortcut worked in both cases and the target field was adapted after I double-clicked it.
It looks like Microsoft has addressed this issue in one of the past updates.
Please somebody confirm this.
If you can set a system variable (something like %MyGameFolder%), then you can use that in your paths and shortcuts, and Windows will fill in rest of the path for you (that is, %MyGameFolder%\data\MyGame.exe
).
Here is a small primer. You can either set this value via a batch file, or you can probably set it programmatically if you share how you're planning to create your shortcut.
I tried %~dp0 in the Start in field and it is working fine in Windows 10 x64
You can make a relative shortcut manually by changing the file path. First in the usual context-menu you create a new shortcut of Windows for your file and in the properties -> location of your file:
%windir%\explorer.exe "..\data\run.bat"
The link with a relative path can be created using the mklink command on windows command line.
mklink /d \MyDocs \Users\User1\Documents
This might be the best way to create link because apparently, the behaviour of shortcut can be different perhaps based on the way they are created (UI vs mklink command). I observed some strange behavior with how the shortcuts behave when I change the root folder.
Try using Relative (a Windows command-line application).
Basically, a shortcut could have a relative link, but Windows gives no way to actually make one.