WAD MKLINK File symlinks are absolute

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Oct 29, 2008
83
0
#1
MKLINK is creating absolute file symlinks when /a is not used.

Code:
56.6G C:\tmp1> touch /c foo
2011-12-30 16:21:50.287  C:\tmp1\foo

56.6G C:\tmp1> mklink bar foo
Symbolic link created for bar <<===>> C:\tmp1\foo

56.6G C:\tmp1> dir

 Volume in drive C is OS             Serial number is 32f0:9b4c
 Directory of  C:\tmp1\*

2011-12-30  16:21         <DIR>    .
2011-12-30  16:21         <DIR>    ..
2011-12-30  16:21     <SYMLINK>    bar [C:\tmp1\foo]
2011-12-30  16:21               0  foo
                 0 bytes in 2 files and 2 dirs
    60,780,445,696 bytes free
 
Oct 29, 2008
83
0
#3
Yes. If you, for example, move tmp1 to D:, it would be nice if bar was still pointing at foo, rather than at a nonexistent file in a nonexistent directory. This is also a cmd compatibility issue:
Code:
C:\Users\johnb\tmp0> echo.>foo
 
C:\tmp0> mklink bar foo
symbolic link created for bar <<===>> foo
 
C:\tmp0> dir
Volume in drive C is OS
Volume Serial Number is 32F0-9B4C
 
Directory of C:\tmp0
 
2011-12-30  19:25    <DIR>          .
2011-12-30  19:25    <DIR>          ..
2011-12-30  19:25    <SYMLINK>      bar [foo]
2011-12-30  19:24                2 foo
              2 File(s)              2 bytes
              2 Dir(s)  59,592,462,336 bytes free
I can use Hermann Schinagl’s ln.exe to do it if you really object to adding it, but then I have to think about it because that command has the link and target in opposite order.
 
May 31, 2008
376
2
#5
Are you sure that Windows will actually move a relative link to another disk?
Don't know about another disk, but CMD does move a relative file symlink (with a non-existent target) to another folder.
Code:
[C:\test]cmd
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2010 Microsoft Corporation. All rights reserved.
 
C:\test>mkdir dA
 
C:\test>mklink dA\linkB B
symbolic link created for dA\linkB <<===>> B
 
C:\test>dir /S
 
Directory of C:\test
 
01/01/2012 09:51 AM <DIR> dA
0 File(s) 0 bytes
 
Directory of C:\test\dA
 
01/01/2012 09:51 AM <SYMLINK> linkB [B]
1 File(s) 0 bytes
 
Total Files Listed:
1 File(s) 0 bytes
5 Dir(s) 71,142,207,488 bytes free
 
C:\test>move dA dB
1 dir(s) moved.
 
C:\test>dir /S
 
Directory of C:\test
 
01/01/2012 09:51 AM <DIR> dB
0 File(s) 0 bytes
 
Directory of C:\test\dB
 
01/01/2012 09:51 AM <SYMLINK> linkB [B]
1 File(s) 0 bytes
 
Total Files Listed:
1 File(s) 0 bytes
5 Dir(s) 71,142,207,488 bytes free
 
C:\test>echo text >dB\B
 
C:\test>type dB\linkB
text
 
Oct 29, 2008
83
0
#6
Windows will not move a directory containing relative symlinks without help (they are converted to files). However, consider where the symlink is on an NTFS-formatted external drive that is E: on one machine but D: on another.
 
#7
Windows will not move a directory containing relative symlinks without help (they are converted to files). However, consider where the symlink is on an NTFS-formatted external drive that is E: on one machine but D: on another.
Or it can be C: (internal) on its own system, but mapped to another letter on another system (Z: is the first choice). Only relative links are mappable. It is one of the reasons I am considering upgrading to Win7.