Sunday, January 2, 2011

File System links in Windows Vista/7

MKLINK.exe

no argument: FILE symbolic link (like a shortcut but not stored as a .lnk file)
/D: DIRECTORY symbolic link (like a shortcut but not stored as a .lnk file)
/H: FILE junction (hard link) (think of data deduplication; only one physical FILE but multiple logical locations)
/J: DIRECTORY junction (hard link) (think of data deduplication; only one physical DIRECTORY but multiple logical locations)

I've only ever used /J for directory links.

Directory Linker, a nifty GUI for creating symbolic links: http://dirlinker.codeplex.com/

NOTE: The first two methods use 'symbolic links' which may fail when used across network drive mappings. ("The symbolic link cannot be followed because its type is disabled") In this case, the fsutil utility may need to be used to enable the various symbolic link 'types': R2R, L2L, L2R, R2L.

fsutil behavior set SymlinkEvaluation L2L:1 R2R:1 L2R:1 R2L:1

"fsutil.exe" can be made to show what arguments it takes by simply running:

fsutil behavior set /?
The symbolic-link resolution behavior is set on the machine that accesses a given link, not the machine that hosts it.

The behavior codes for "fsutil.exe", namely "L2L", "L2R", "R2L", and "R2R", mean the following:

"L" stands for "Local", and "R" for "Remote" (who would've thunk?)
The FIRST "L" or "R" - before the "2" - refers to the location of the link itself (as opposed to its target) relative to the machine ACCESSING the link.
The SECOND "L" or "R" - after the "2" - refers to the location of the link's target relative to the machine where the LINK itself is located.
Thus, for instance, enabling "R2L" means that you can access links located on a remote machine that point to targets on that same remote machine.

More Info:
stackoverflow.com