Very old thread update: after reading this topic (as well as other resources) I settled on a variation of the command below for the shortcut properties 'Target' field coupled with the 'Run: Minimized' option whenever I need to create a portable shortcut (.lnk) file:
Code: Select all
%COMSPEC% /C "START "" "%CD%\ProgName" CommandLineParameter(s)"
(please, heed the repeated double quotes...)
[EDIT: And then replace the path in the "Start in:" field with '%CD%'.]
[Also, If you'd like to change the icon of the resulting shortcut to something more meaningful than the default command console icon and don't want to be browsing through your whole filesystem via an unwieldy "Open file" dialog, you'll have to somehow copy the absolute path to the target executable, click on the "Change icon..." button, paste it in the "Look for icons in this file" field, and then click "Browse..." to chose the intended file and icon -- and don't worry with the absolute path being recorded, it'll automagically follow your shortcut. Yewh!]
[All credit goes to ashghost, who first showed me a way to do all this.]
BTW, while the /MIN switch is well known, there seems to exist an undocumented /S parameter for the START command that will run a console program without displaying the console window (further reports appreciated!). I haven't tested this extensively, so YMMV...
The lnker.exe console utility kindly provided by m^2 here has gone AWOL, but something he stated previously (viewtopic.php?p=13329#p13329) about the relative vs absolute nature of the paths included in shortcut files came back to me when I found a page (partly) about muting undesirable behavior via the system's registry:
Code: Select all
REGEDIT4
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
"LinkResolveIgnoreLinkInfo"=dword:00000001
[When set to 1] Windows only searches the current target path. It does not search for the original path even when it cannot find the target file in the current target path.
Shortcut files typically include an absolute path to the original target file as well as the relative path to the current target file. When the system cannot find the file in the current target path, then, by default, it searches for the target in the original path. If the shortcut has been copied to a different computer, the original path might lead to a network computer, including external resources, such as an Internet server.
It concerns Windows 2000, but I believe it remains valid(?). Posting this here might benefit future generations...
EDIT: another related utility is Relative (see viewtopic.php?t=21250).
BTW, since Windows Vista, an internal CLI command is available for managing filesystem symbolic links: mklink (for info, see http://ss64.com/nt/mklink.html).
portable%20shortcuts shortcut%20portable lnk