mklink

Create a symbolic link.

fsutil hardlink

Create or list hard links to a file.

Examples

REM Help
mklink
mklink /?

REM Create a symbolic link to a file
REM Give name a .link extension to see
REM Windows recognize this file as a
REM .symlink in file explorer (Type column)
mklink <link_name> <target_filename>

REM Create a hard link to a file.
REM Hard link to a directory not supported.
mklink /H <newFileName> <existingFileName>
REM or
fsutil hardlink create <newFileName> <existingFileName>

REM Create a symbolic link to a directory
REM (soft link to a directory)
mklink /D <link_name> <target_dir>

REM Create a directory Junction Point
REM (soft link to a directory, behaves like a hard link)
mklink /J

REM List all links in the current directory
REM Hard links are not listed
dir /aL

REM List all hard links for filename
fsutil hardlink list <filename>

REM Delete a junction or symbolic link to a directory.
rmdir <junction name>

REM Delete a symbolic link to a file.
del <link name>

Hard links

  • Most “files” are hard links to files.
  • Hard links don’t have the L attribute, so dir /aL doesn’t list them.
  • There is no dir option to get attributes indicating a hard link to a file because hard links are no different than “regular” files.
  • Hard links and their targets do not differ in file type.
  • Both are just names to the same MFT entry.

Soft Links

  • Soft links are made by the /D or /J option of mklink.
  • Symbolic Links and Junction Points are both soft links.
  • In apparent contradiction to the previous statement, this article about mklink states that the /J option is the hard-link equivalent of the /D option, a soft link. However, this does not seem to be true. See TechNet Thread for differences between the /D option (SYMLINKD) and /J (JUNCTION) option.

Windows Shortcuts

  • They are a feature of explorer.exe, the Windows file manager, not a feature of the file system.
  • The mklink command cannot be used to create Windows shortcuts (.lnk extension).
  • There does not seem to be a command-line command for creating .lnk shortcuts.

Differences

The main difference between a soft and hard link is that a soft link references its target by name. A hard link, in contrast, points to the same MFT entry as the target file; thus, if you delete the “original” target file, the MFT entry remains as long as the link still exists, and the link can continue to access the file. In this sense, the link and the target are on equal footings: only when all hard links to the MFT entry are deleted does the system remove the original file from storage.

Share Drives

If you attempt to create a link to a file on a share drive, you get the following message:

Local NTFS volumes are required to complete the operation.

although I have only tested this using the /h option.

Reparse Points

Mount Points

Mount points are reparse points. Add a mount point to an existing volume to give the illusion of extending space on that volume. The mount point, which appears like a folder on the volume to be extended, actually points to a path on another volume. Creating mount points is done via the Disk Management MMC. The old DOS way of doing this was using the join command (no longer supported in windows) join was replaced by linkd, itself later replaced by mklink. All these techniques are roughly the equivalent of the mount command in UNIX.

Further Reading