When Windows Vista is first launched, I was impressed by the introduction of the long-waited symbolic links feature. As far as I knew, there were only hard links in NTFS. Soft links (Symbolic links) are often simulated by using shortcuts (.lnk files), but however you cannot cd into them or make them part of a path (e.g. C:\MyHome.lnk\Desktop) like what you can do on soft links. This is inconvenient especially for those command line lovers.
However, recently I found that I have missed something useful, the directory junctions (aka Reparse points) in NTFS since Windows 2000. Directory Junctions are just like soft links, but it can only be applied on directories (as you may know from its name), which is useful enough in most cases. Sadly enough, not many people heard about directory junctions (hard links either) because Microsoft provided no built-in tools to handle them.
So here is a (incomplete) list of useful tools on managing directory junctions and hard links:
- Junction by Sysinternals (acquired by MS) supports querying, creating and deleting directory junctions
- Linkd.exe, Delrp.exe and MountVol.exe from Microsoft Windows 2000 Resource Kit can also handle directory junctions, for details please read here
- Fsutil from Microsoft (starting from Windows XP) supports creating hard links, querying and deleting directory junctions (reparse points)
- ln from CoreUtils package of GnuWin32 project can create hard links on Windows
- NTFS Link Shell Extension byHermann Schinagl integrates with the Windows Explorer to let you manage hard links and junctions through GUI
- hlscan.exe also from Microsoft Windows 2000 Resource Kit allows you to find all hard links in the NTFS volume.
- Mklink from Microsoft (starting from Windows Vista) allow managing soft links, hard links and directory junctions
If you would like to manage junctions using the low level Windows API, you may find this page useful.
BTW, I noticed some interesting behavior of directory junctions. Try the following if you are interested:
- mkdir A to create a folder named "A"
- mkdir A\C to create a sub-folder named "C" in A
- junction B A to create a directory junction named "B" referencing A
- rmdir /s A to remove A and its subordinates
- junction -d B or rmdir B to remove B