I'm using Shortcut.exe to make a shortcut for a program in tandem with another batch script. I can easily make a shortcut with a pre-defined path to the program as well as it's shortcut path, but I cannot use an ambiguous path such as .\
. I want to run my script alongside Shortcut.exe and the target executable without defining the executables literal path as it will depend on where the end-user places the script that makes the shortcut. Here is my current working script:
Shortcut.exe
shortcut /a:c /f:"%LINKTARGET%" /t:"%TARGETEXECUTABLE%"
I want to use something along these lines:
Shortcut.exe
shortcut /a:c /f:"%USERPROFILE%\Desktop\%LINKNAME%.lnk" /t:".\%TARGETEXECUTABLE%"
How do I define an executable within the same location as my script and Shortcut.exe?
%~dp0
cd
andcd..
. Thank you for the reply though.shortcut /a:c /f:"%USERPROFILE%\Desktop\%LINKNAME%.lnk" /t:"%~dp0%TARGETEXECUTABLE%"
should do.%~dp0
already contains a trailing slash.