Wiki‎ > ‎Windows‎ > ‎

Hard links, Symlinks and Junctions

Some general information on these types of links in Windows.

Using MKLink (syntax, examples etc)

Hard Links
Deleting a hard link via the command line will delete the LINK and reduce the LINK-COUNT by 1. When the the link-count is one, the contents of the file/folder is delete also.

Symbolic Links

You can identify a symlink via the command link:
Dir C:\test
...
Directory of C:\test

04/14/2006 11:24 AM <DIR> .
04/14/2006 11:24 AM <DIR> ..
04/14/2006 11:24 AM <SYMLINKD> bar [c:\windows]
04/14/2006 11:24 AM <SYMLINK> foo [c:\Windows\system32\notepad.exe]
...

If you have a symbolic link that is a directory (made with mklink /d) then using del will delete all of the files in the target directory (the directory that the link points to), rather than just the link.

To remove a symlink to a folder, use RD (or RMDIR).
To remove a symlink to a file, use DEL.

For example, typing RD C:\users\margaret\dropbox\margaret will remove the symlink in the dropbox folder, but not the target (user's profile).

Junctions (a.k.a. reparse points)

These can point only to folders, not to files. They work much like symbolic links (so that, for example, moving the target folder will cause the junction to point to nothing). They can be used to point to any folder, and even to drives the same PC, but but not to mapped networked drives.

Further reading

On using MKLINK: http://www.mydigitallife.info/create-symbolic-links-hard-links-and-directory-junctions-in-vista-with-mklink/

On the different kinds of links (inlcuding API info): http://www.flexhex.com/docs/articles/hard-links.phtml
Comments