This web page implies that it is possible to make symbolic links with relative paths using mklink.
I have tried all sorts of ways to make relative symbolic links, but I always end up with an absolute path.
How is it done?
This web page implies that it is possible to make symbolic links with relative paths using mklink.
I have tried all sorts of ways to make relative symbolic links, but I always end up with an absolute path.
How is it done?
Symbolic links are relative by default. You have to explicitly write a drive letter to make any part of the link absolute.
The general syntax for a symbolic link is:
mklink link destination
So, to create a relative symbolic link: link is going to be a path relative to your working directory, and destination is going to be a path relative to link.
Examples:
1. mklink link.txt ..\destination.txt
This creates a symbolic link for link.txt which points to destination.txt one folder up.
You can move link.txt around, and it will always point to destination.txt one folder up.
2. C:\>mklink A\Link.txt ..\Destination.txt
This creates a symbolic link C:\A\Link.txt for C:\Destination.txt
mklink destination.txt "documentation\readme.txt" will point to a child folder called documetation" and a file in that folder called readme.txt*.
– surfasb
Nov 27 '11 at 08:47
CMD, but not in TCC/LE, which is what I have been using. I am surprised that it is altering (expanding) path arguments for external programs.
– paradroid
Nov 27 '11 at 09:20
To make relative link to a directory use /D switch
For example:
mklink /D lib\foo ..\foo
Links directory foo from parent directory as lib\foo.
When the link is moved to another directory, it will still point to ..\foo in a relative sense.
Junctions created using /J switch can have relative path specified at the time of creation, however this path is resolved and junction will always point to an absolute path.
/J switch is for making junctions, which are hardlinks, not symbolic links and has nothing to do with relative paths.
– paradroid
Feb 02 '23 at 19:57
/J switch makes the link absolute even when at the time of creation relative path was given.
– infi
Feb 16 '23 at 03:53
/d creates), but it is true that they always use an absolute path. You can use fsutil reparsePoint query to see what path is stored inside a symlink or a junction. (Real hardlinks would not be reparse points at all.)
– u1686_grawity
Feb 16 '23 at 14:13