Relative program links (*.lnk)

  • Thread starter Thread starter Martin Cetkovsky
  • Start date Start date
M

Martin Cetkovsky

Hi,

I have tested using VBS that Windows supports relative links (for example
'homer.lnk' links to the '../aa/destination.doc'). When I am tring to create
the link using Windows API, the relative path is changed and (as I see)
refers over the root (for example it is changed to
'../../../../aa/destination.doc'). So how can I create the realive links?

Thanks.

Martin
 
SUB CreateShortCut(sLoc, sPgm, sWorkDir)
on error resume next
Dim sName 'Shortcut Name
' Create Shortcut Object based on Location desired
Set sName = WSHShell.CreateShortCut(sLoc)

' Set Properites and save the changes
sName.TargetPath = sPgm
sName.WorkingDirectory = sWorkDir
'sName.WindowStyle = iStyle
'sName.IconLocation = sIcon
sName.Save
if err.number <> 0 then
Eventlog.writeline("! Error: " + err.description + " " + err.number)
end if
on error goto 0
END SUB

hopefuly this is what you searching for

georg
 
Thank you, but it seems to be the same I have been testing...

So I including the script I have used for testing:
(the code bellow is in JS, but its the same, the final version will be in
Delphi - there is the same problem)
var WshShell = WScript.CreateObject("WScript.Shell");
var oShellLink = WshShell.CreateShortcut("Shortcut Script.lnk");
oShellLink.TargetPath = "ck\\ck.exe"; // or .\\ck\\ck.exe
oShellLink.WorkingDirectory = "ck\\"; // or .\\ck\\
oShellLink.Save();

The script is in the C:\Program Files directory.

When I run it, the shortcut is created, but the parameters are slight
different:
Target: ..\ck\ck.exe
Working directory: as in the code

I have tried to run it from another locations and I see, there is added the
"..\" to the start of the target path, so the path is "going throught" the
root directory. But I do NOT want this "feature". I need the path I set as a
property, not the path the function saves.

Thank you.

Martin
 
Hi, you can try symlinks in cygwin:
ln -s file file_lnk
It supports relative symlinks.
I'm not sure what the defference between cygwin symlink and shortcut created by VBS.
 
Back
Top