Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
    
MSDN has a strange way of explaining this. I had a hard time understanding how to make a symbolic link, since there are no actual examples. –  iglvzx Nov 27 '11 at 8:06
    
The only reason I know this "strange way" is because MSDOS use this method. –  surfasb Nov 27 '11 at 8:50

1 Answer 1

up vote 9 down vote accepted

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

share|improve this answer
    
This is it. Rather than beginning with a drive letter or a backslash, you just begin with a directory. eg 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 8:47
    
@surfasb, @iglvzx: At first I was confused, as that is exactly what I have been trying. But as you both confirm that this works, I have realised that it does work in 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 9:20
    
@surfasb: This problem with TCC/LE has been fixed with the new v13, but happened with 12.11.76, which I had been using. –  paradroid Nov 28 '11 at 9:58
    
@paradroid: I'm glad it is working out. I remember fondly the old old version of TCC. How long have you been using it now? On another not, yeah, the nuances of PATH enumeration boggles my mind. And the obligatory [blog post]:(blogs.msdn.com/b/oldnewthing/archive/2005/11/22/495740.aspx) about how past MS-DOS decisions towards compatibility still affects us today. –  surfasb Nov 28 '11 at 14:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.