Issue: MKLINK /J creates invalid link [TCC 14.03.53]

May 31, 2008
382
2
#1
Unlike MKLNK, MKLINK /J does not automatically replace the relative path of a junction target with an absolute path. This results in an invalid junction. Possible work-arounds: applying @FULL to MKLINK's target; using MKLNK instead of MKLINK /J.
JPSoft could classify this issue as either WAD or bug.
Code:
0>c:\temp

0>mkdir ddd

0>mklink /J ddd-mklink .\ddd
Junction created for ddd-mklink <<===>> .\ddd

0>dir /k /m ddd-mklink

TCC: (Sys) The system cannot find the file specified.
"C:\temp\ddd-mklink\*"

0>mklnk .\ddd ddd-mklnk
C:\temp\ddd-mklnk -> C:\temp\ddd

0>dir /k /m ddd-mklnk

1/03/2013 16:39 <DIR> .
1/03/2013 16:39 <DIR> ..

0>dir /k /m ddd*
1/03/2013 16:39 <DIR> ddd
1/03/2013 16:40 <JUNCTION> ddd-mklink [.\ddd]
1/03/2013 16:39 <JUNCTION> ddd-mklnk [C:\temp\ddd]

0>ver

TCC 14.03.53 Windows 7 [Version 6.1.7601]
 
#2
The /A option does it for you! BTW, relative links are extremely useful (more than absolute ones required for junctions), because moving the whole tree (both the source and target of the link) to a different position in the file system, or copying it, a relative path retains the linkage, an absolute one does not.
 

rconn

Administrator
Staff member
May 14, 2008
10,426
95
#3
Unlike MKLNK, MKLINK /J does not automatically replace the relative path of a junction target with an absolute path. This results in an invalid junction. Possible work-arounds: applying @FULL to MKLINK's target; using MKLNK instead of MKLINK /J.
JPSoft could classify this issue as either WAD or bug.
WAD, for compatibility with CMD. As Steve said, use /A if you want an absolute path.
 
May 31, 2008
382
2
#4
This bites me often; I'm in the habit of checking for options with /? on the command line, instead of viewing the full help topic with F1. So I missed option /A of MKLINK because it isn't included in the /? help summary. I paid the price of my lazyness.
 
May 31, 2008
382
2
#5
WAD, for compatibility with CMD. As Steve said, use /A if you want an absolute path.
Rex, apparently CMD's MKLINK /J creates absolute paths regardless of its target being specified as a relative path. Shouldn't TCC's MKLINK /J do the same instead of requiring /A ?
Code:
0>c:\temp

0>mkdir ddd

0>cmd /c mklink /J ddd-cmd .\ddd
Junction created for ddd-tcc <<===>> .\ddd

0>dir /k /m ddd-cmd

Directory of C:\temp\ddd-cmd\*

07/01/2013 11:12 <DIR> .
07/01/2013 11:12 <DIR> ..

0>mklink /J ddd-tcc .\ddd
Junction created for ddd-tcc <<===>> .\ddd

0>dir /k /m ddd-tcc

TCC: (Sys) The system cannot find the file specified.
"C:\temp\ddd-tcc\*"

0>dir /k /m ddd*

07/01/2013 11:12 <DIR> ddd
07/01/2013 11:13 <JUNCTION> ddd-cmd [C:\temp\ddd]
07/01/2013 11:14 <JUNCTION> ddd-tcc [.\ddd]

0>ver

TCC 14.03.53 Windows 7 [Version 6.1.7601]