I have a game that uses this file structure:
GAME FOLDER
->data
->data->run.bat
I want to put a shortcut to run.bat
in GAME FOLDER, but if I move it, or someone else installs it it won't work, because the target is wrong. Is there a way to make the target and "start in" relative to GAME FOLDER?
Right click on your /bat/ folder and click Create Shortcut.
bat - Shortcut
in the current directory.Shortcut to bat
.Right click on the shortcut you just created and click Properties.
Change Target (under the Shortcut tab on Windows 7) to the following:
%windir%\system32\cmd.exe /c start "" "%CD%\bat\bat\run.bat"
Make sure Start in is blank. That causes it to start in the current directory.
That's probably acceptable in the case of shortcutting to a .bat but if you want to change the icon, open the shortcut's properties again and click Change Icon... (again, under the Shortcut tab on Windows 7). At this point you can Browse... for an icon or bring up a list of default system icons by entering
%SystemRoot%\system32\SHELL32.dll
to the left of the Browse...
button and hitting Enter. This works on Windows 7 and Windows XP but the icons are different due to style updates (but are recognizably similar). Depending on the version of Windows the shortcut resides, the icon will will sometimes change accordingly.
More Info:
See Using the "start" command with parameters passed to the started program to better understand the empty double-quotes at the beginning of the first Target command.
According to Microsoft, if you leave the 'Start In'
box empty, the script will run in the current working directory. I've tried this in Windows 7 and it appears to work just fine.
Source: http://support.microsoft.com/kb/283065
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With