Windows - How to Make a Symbolic Link with a Relative Path Using Mklink?

mklinksymbolic-linkwindows

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?

Best Answer

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