Windows 7: Symbolic & Hard Links

If you are coming from the Linux world you are probably familiar with symbolic and hard links. I recently discovered a very similar feature implemented in the NTFS file system, which enables you to create Symbolic Links and Junction Points in Windows Vista and Windows 7 by utilizing the mklink command.

The mklink command is used to create a symbolic link. It has the following command line syntax:
mklink [[/D] | [/H] | [/J]] link target
  • /D – Creates a directory symbolic link. Can also point to a remote SMB network path.
  • /H – Creates a hard link instead of a symbolic link.
  • /J – Creates a Directory Junction. Can only point to directories on the same volume.
  • If no arugement is specified, mklink creates a file symbolic link.
  • link – Specifies the new symbolic link name.
  • target – Specifies the path (relative or absolute) that the new link refers to.
Just like ordinary files and folders, del and rmdir can be used to delete the symbolic links to files and directories respectively.
To delete symbolic link to a file, the following command line syntax can be used:
del filename
  • filename – Specifies the name of the file/symbolic link to be deleted
To delete symbolic link to a folder, the following command line syntax can be used:
rmdir directoryname
  • directoryname – Specifies the name of the folder/symbolic link to be deleted

For those who are interested here's a list of related articles with some more background information about the NTFS file system, Symbolic Links and Junction Points:

1 comment:

  1. Probably worths mentioning the subst command to have a new hard drive entry for a deep folder.

    ReplyDelete