Re: Portable links (i.e., Windows relative shortcuts)

Share interesting information or links related to portable apps here.
Post Reply
Message
Author
User avatar
Midas
Posts: 6717
Joined: Mon Dec 07, 2009 7:09 am
Location: Sol3

Re: Portable links (i.e., Windows relative shortcuts)

#1 Post by Midas »

[Moderator note: older posts in this topic have been split from their original thread (@viewtopic.php?t=3640), because it being such an old topic made it quite difficult to retrieve when needed... I'm hoping the split will facilitate it.]

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... :mrgreen:

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

Marc
Posts: 165
Joined: Sun May 15, 2011 6:06 pm

Re: Portable .lnk files

#2 Post by Marc »

I'm starting to wonder if for audio files it isn't better to use playlist files which can be crerated with relative paths. Foobar can't correctly interpret windows shortcuts and is unable to play the redirected tracks.
Winamp can play them but it reports the path of the audio files such as

Code: Select all

C:\DOCUME~1\Marc\ESCRIT~1\SELECC~1\013128~1.SEL\01629A~1.CAR\ADELE-~3.MP3
The problem is that I'm unaware of any way to create a single playlist file for each audio file, so that each playlist contains only one track.

billon
Posts: 843
Joined: Sat Jun 23, 2012 4:28 pm

Re: Portable .lnk files

#3 Post by billon »

XMPlay can play shortcuts without any problems and displays paths correctly. It can also create playlist with only one track.
fubar sux

Marc
Posts: 165
Joined: Sun May 15, 2011 6:06 pm

Re: Portable .lnk files

#4 Post by Marc »

billon wrote:It can also create playlist with only one track.
I meant in batch.

billon
Posts: 843
Joined: Sat Jun 23, 2012 4:28 pm

Re: Portable .lnk files

#5 Post by billon »


Marc
Posts: 165
Joined: Sun May 15, 2011 6:06 pm

Re: Portable .lnk files

#6 Post by Marc »

These are nice apps, but as far as I can tell they cant batch create separated playlists containing one track each, for a large number of files.

Marc
Posts: 165
Joined: Sun May 15, 2011 6:06 pm

Re: Portable .lnk files

#7 Post by Marc »

The link for Inker is down. It isn't either in wayback machine. Maybe someone can upload it :roll:
Probably a foolish question does it create a portable .Ink file or modify an existing non-relative shortcut?
Relative seems to be of the first type.

User avatar
Midas
Posts: 6717
Joined: Mon Dec 07, 2009 7:09 am
Location: Sol3

Re: NiftyLink

#8 Post by Midas »

NiftyLink (http://luethje.eu/prog/niftylink_en.htm) is yet another solution for the relative path shortcut conundrum. It was designed as a Total Commander plugin, but runs well enough by itself and in a portable fashion.
NiftyLink is a 32 bit program for Windows 2000/XP/Vista/7, that integrates with Windows Explorer, and provides additional functionality as portable add-on for Total Commander (v7.50+). It allows creation and execution of special links to directories, files, and internet addresses. These links provide possibilities, that are not given with any standard Windows link (LNK file, junction, symbolic link, or hard link).


Image


NiftyLink v1.10a, dated 2012-11-06, can be downloaded from http://luethje.eu/prog/.

IMHO, on Windows Vista and newer, the easiest and quickest way to deal with this is by generating symbolic links containing relative paths using the above mentioned mklink CLI command. Should you decide to go this way, however, discretion should be used on the shortcomings quoted by lautrepay at the Relative topic.

Anyone still running Windows XP should probably check NTFS Link (https://elsdoerfer.name/ntfslink), which while not specifically designed to solve the current problem gives a better overview of that OS linking capabilities.

BTW, the pointer came from a somewhat related topic at viewtopic.php?t=14796.

User avatar
Midas
Posts: 6717
Joined: Mon Dec 07, 2009 7:09 am
Location: Sol3

Re: Portable links (i.e., Windows relative shortcuts)

#9 Post by Midas »

Another piece of information on Windows filesystem path conventions and rules that will nicely complement the old information above I still rely on to this day... (Head over for further details.) :idea:
Absolute path formats
Name Example
Drive path C:\Program Files\HAL 9000
UNC path \\Media\Pictures\Worth\1000 words
Device path (literal) \\?\D:\Plans\Marshall
Device path (normalized) \\.\D:\Projects\Human Genome
Relative path formats
Name Examples
Current directory-relative .\Manhattan, ..\Plans
Current drive-relative \Pacts
Drive's current directory-relative D:Warsaw

Also, an alternative to NiftyLink above, an utility I still rely on -- in what has been like forever -- to handle hard/symbolic links in Windows -- which BTW are a different matter altogether to relative links, i.e., Windows only special format files with LNK/URL extension -- is Link Shell Extension viewtopic.php?t=21467...

Post Reply