WAD MKLINK CMD compatibility, MKLINK /X

May 31, 2008
382
2
I noticed two new issues:
1) TCC MKLINK targets absolute file paths vs CMD which targets relative file paths, when given
2) MKLINK /X (not in CMD) fails with "the directory name is invalid" when asked to delete a file symlink.
You will notice those issues by comparing the two console logs below - first one is CMD's.
OT: is there a way to post a code/quote blocks within a spoiler?
Code:
C:\test2>cmd
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2010 Microsoft Corporation. All rights reserved.

C:\test2> echo.>file

C:\test2> mkdir folder

C:\test2> mklink flink file
symbolic link created for flink <<===>> file

C:\test2> mklink /D dlink folder
symbolic link created for dlink <<===>> folder

C:\test2> mklink notflink notfile
symbolic link created for notflink <<===>> notfile

C:\test2> mklink /D notdlink notfolder
symbolic link created for notdlink <<===>> notfolder

C:\test2> mklink flinkrel ..\test2\file
symbolic link created for flinkrel <<===>> ..\test2\file

C:\test2>dir
Volume in drive C has no label.
Volume Serial Number is 50A9-A297

Directory of C:\test2

12/30/2011 05:59 PM <DIR> .
12/30/2011 05:59 PM <DIR> ..
12/30/2011 05:59 PM <SYMLINKD> dlink [folder]
12/30/2011 05:58 PM 2 file
12/30/2011 05:58 PM <SYMLINK> flink [file]
12/30/2011 05:58 PM <SYMLINK> flinkrel [..\test2\file]
12/30/2011 05:58 PM <DIR> folder
12/30/2011 05:59 PM <SYMLINKD> notdlink [notfolder]
12/30/2011 05:59 PM <SYMLINK> notflink [notfile]
3 File(s) 2 bytes
5 Dir(s) 63,138,361,344 bytes free

C:\test2>del dlink
C:\test2\dlink\*, Are you sure (Y/N)? N

C:\test2>rmdir dlink

C:\test2>del flink

C:\test2>del flinkrel

C:\test2>rmdir notdlink

C:\test2>del notflink

C:\test2>dir
Volume in drive C has no label.
Volume Serial Number is 50A9-A297

Directory of C:\test2

12/30/2011 06:12 PM <DIR> .
12/30/2011 06:12 PM <DIR> ..
12/30/2011 05:58 PM 2 file
12/30/2011 05:58 PM <DIR> folder
1 File(s) 2 bytes
  3 Dir(s) 63,138,349,056 bytes free
Code:
C:\test>ver

TCC LE 13.03.36 Windows 7 [Version 6.1.7601]

C:\test> >file

C:\test> mkdir folder

C:\test> mklink flink file
Symbolic link created for flink <<===>> C:\test\file

C:\test> mklink /D dlink folder
Symbolic link created for dlink <<===>> folder

C:\test> mklink flinkrel ..\test\flink
Symbolic link created for flinkrel <<===>> C:\test\file

C:\test> mklink notflink notfile
Symbolic link created for notflink <<===>> C:\test\notfile

C:\test>mklink /D notdlink notfolder
Symbolic link created for notdlink <<===>> notfolder

C:\test>dir

Volume in drive C is unlabeled Serial number is 50a9:a297
Directory of C:\test\*

12/30/2011 17:55 <DIR> .
12/30/2011 17:55 <DIR> ..
12/30/2011 17:52 <SYMLINKD> dlink [folder]
12/30/2011 17:27 <DIR> folder
12/30/2011 17:55 <SYMLINKD> notdlink [notfolder]
12/30/2011 17:27 0 file
12/30/2011 17:55 <SYMLINK> flink [C:\test\file]
12/30/2011 17:55 <SYMLINK> flinkrel [C:\test\file]
12/30/2011 17:55 <SYMLINK> notflink [C:\test\notfile]
0 bytes in 3 files and 5 dirs
63,138,361,344 bytes free

C:\test>del dlink
C:\test\dlink\* : Are you sure (Y/N)? N
0 files deleted

C:\test>rmdir dlink

C:\test>del flink
Deleting C:\test\flink
1 file deleted

C:\test>del flinkrel
Deleting C:\test\flinkrel
1 file deleted

C:\test>rmdir notdlink

C:\test>del notflink
Deleting C:\test\notflink
1 file deleted

C:\test>dir

Volume in drive C is unlabeled Serial number is 50a9:a297
Directory of C:\test\*

12/30/2011 18:13 <DIR> .
12/30/2011 18:13 <DIR> ..
12/30/2011 17:27 <DIR> folder
12/30/2011 17:27 0 file
0 bytes in 1 file and 3 dirs
63,138,349,056 bytes free

C:\test>mklink flink file
Symbolic link created for flink <<===>> C:\test\file

C:\test>mklink /D dlink folder
Symbolic link created for dlink <<===>> folder

C:\test>mklink flinkrel ..\test\flink
Symbolic link created for flinkrel <<===>> C:\test\flink

C:\test>mklink notflink notfile
Symbolic link created for notflink <<===>> C:\test\notfile

C:\test>mklink /D notdlink notfolder
Symbolic link created for notdlink <<===>> notfolder

C:\test>mklink /X flink
TCC: (Sys) The directory name is invalid.
"flink"

C:\test>mklink /X dlink

C:\test>mklink /X flinkrel
TCC: (Sys) The directory name is invalid.
"flinkrel"

C:\test>mklink /X notflink
TCC: (Sys) The directory name is invalid.
"notflink"

C:\test>mklink /X notdlink

C:\test>dir

Volume in drive C is unlabeled Serial number is 50a9:a297
Directory of C:\test\*

12/30/2011 18:17 <DIR> .
12/30/2011 18:17 <DIR> ..
12/30/2011 17:27 <DIR> folder
12/30/2011 17:27 0 file
12/30/2011 18:15 <SYMLINK> flink [C:\test\file]
12/30/2011 18:15 <SYMLINK> flinkrel [C:\test\flink]
12/30/2011 18:15 <SYMLINK> notflink [C:\test\notfile]
0 bytes in 4 files and 3 dirs
63,138,349,056 bytes free
 

rconn

Administrator
Staff member
May 14, 2008
12,356
150
I noticed two new issues:
1) TCC MKLINK targets absolute file paths vs CMD which targets relative file paths, when given

WAD -- this is a feature.

TCC will use relative paths for creating directory links, but nobody has ever come up with a reason why you would want relative file links. TCC expands the filename so you can see what you're really getting (frequently different from what you think you're doing!).
 
May 31, 2008
382
2
WAD -- this is a feature.

TCC will use relative paths for creating directory links, but nobody has ever come up with a reason why you would want relative file links. TCC expands the filename so you can see what you're really getting (frequently different from what you think you're doing!).
Rex, if saving the user from himself is your reason for making this feature of MKLINK incompatible with CMD, then I think you could do better; go ahead and show feedback with the fully expanded filepath, but please create a relative file link as CMD does! That way you'll be helpful without breaking compatibility.
Relative file symlinks are supported in *nix and Microsoft Windows (including CMD). Those software engineers must have had good reasons to design this feature this way, I think. Why do you need a supporting case to follow in their steps?
 
  • Like
Reactions: Charles Dye
I think Unix sometimes uses relative file links so the same executable can be run using different names and it will behave differently depending on which name was used. At least, I think these were relative links; it has been a while since I ran into this. I always thought it a bit confusing to have the behavior depend on the name.
 
May 31, 2008
382
2
Good example, thanks David. A similar practice taken from linux involves dlls; a "package" may install different versions of a command in a single folder, with different executables which dynamically link the same dll - under different symbolic names - from the executable folder.
Two advantages of relative file symlinks, in this case: 1) you don't need to change the dll links after the package gets installled; 2) unlike file hardlinks, file symlinks are self-documenting (ls tells you where they point to).
 
Similar threads
Thread starter Title Forum Replies Date
Stefano Piccardi 13.0.31 2 MKLINK TCC vs CMD issues Support 2
Joe Caverly MKLINK and Streams and DEL Support 4
B MKLINK requires admin - fails silently. Support 1
Stefano Piccardi Issue: MKLINK /J creates invalid link [TCC 14.03.53] Support 4
Stefano Piccardi Fixed mklink /X junction\ Support 3
samintz Fixed GPF from MKLINK Support 1
fpefpe Fixed MKLINK Support 2
J WAD MKLINK File symlinks are absolute Support 7
J WAD MKLINK & XP Support 4
Stefano Piccardi Fixed MKLINK /D Support 4
David McClelland MKLINK /x discrepancy Support 0
R No Error Message when running mklink as limited user Support 3
W mklink and Volume Shadow Copies Support 5
N mklnk / mklink problem Support 7
T WAD CMD incompatibility Support 14
sully9 How to? Unexpected %DATE% CMD variable format (vs DATE /T format) in CMDebug Support 1
L FTYPE in TCC, less quirky than in cmd.exe Support 3
Peter Murschall Single-line Do-CMD is a bit uncooperative. Support 6
FreezerBurnt Help making a CMD and TCC compatible batch file Support 7
T Date format date different from cmd Support 7
D Differences between TCC and CMD with COPY /b Support 4
M Oracle batch OPatch.bat.bat not working in TCC but correctly in CMD Support 5
E TCC/CMD difference Support 5
S How to? Deinstalling TC/reinstating execution of bat files by cmd in Win7 Support 31
D How to? Pass OpenHere Folder to CMD? Support 6
R Difference between TCC and CMD: variable names with hyphens Support 4
M WAD "Pictures" directory is empty in TCC but not in CMD or Explorer Support 4
rps Cmd history recall Support 4
rps Documentation TITLE cmd docs Support 0
Joe Caverly PUSHD with UNC path in CMD.EXE Support 2
W Starting program for word to pdf conversion (difference cmd and tcc) Support 13
Joe Caverly Using this CMD technique from TCC Support 17
W If command - different with CMD Support 6
I how to make TCC default/replace cmd.exe? Support 9
R FOR usage error from TCC but not from CMD Support 16
I findstr works in cmd but not in tcc Support 5
D Pasting Unicode data has different behavior on TCC and CMD Support 2
M Command line parsing differences between cmd.exe and TCC Support 6
Joe Caverly Works with CMD.EXE, no output with TCC.EXE Support 7
Joe Caverly tcommand(cmd) Support 13
L WAD ECHO. expansion of non-existent env-vars differs from CMD.exe Support 6
Joe Caverly "Functions" in cmd.exe batch files Support 6
Joe Caverly Works in debugger, not from cmd line Support 1
K CMD, TCC, VisualStudio 2017, VcVars* differences Support 1
D Does TCC improve CMD's implementation of ECHO? Support 6
P Labels in batch files: TCC vs CMD.exe Support 9
Patulus Yet another thread on CMD compatibility Support 16
A Fixed (CMD compat) START /D fails to recognize the switch option. Support 3
Joe Caverly CMD.EXE and filename(1).ext Support 3
H DOS CMD Sort+Add Sequence+Remove Sequence number Support 12

Similar threads