Relative program links (*.lnk)

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
 
G

georgp

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
 
M

Martin Cetkovsky

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
 
Joined
Dec 1, 2005
Messages
1
Reaction score
0
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top