For Unix-like or Linux system users, symbolic link is a common feature in use almost daily. Symbolic link (aka soft link) or symlink as it often shortened to, is a special type of file or file-system object that serves as a reference or points to another file, UNC or directory, known as target. In Windows systems such Windows Vista and Windows Server 2008, e.g. Windows 7, Windows 8, Windows 8.1, Windows 10, Windows Server 2008 R2, Windows Server 2012, Windows Server 2012 R2 and Windows Server 2016, symlinks feature has been added to NTFS filesystem and can be created by using MKLINK command.

In previous Windows operating system such as Windows XP, the closer thing to symbolic links is NTFS junction point, or worse, Windows shell shortcut (.lnk) file.

Symlink in Windows, unlike .lnk shortcut in desktop or Windows Explorer, allow user to access files within the symbolic link created itself via File Explorer, the console and etc. And symbolic link also differ from NTFS junction point which can only link to folders and volumes, in which symlinks can point to a file, a UNC, a folder or a volume, as well as able to span file systems.

Symbolic link is useful when you have a lot of folders and files are scattered all over the directory tree, and you need to manage them from a single location. Another scenario is that you have a deep nested file that you want to access quickly instead of traverse through one branch by one branch. And furthermore, for programmer, symlink provides a static file path that can be point to a ever changing object without affecting the functionality of the program. In all these situation, symbolic links can be created at a convenient location which point to the ‘real’ objects.

As mentioned, to create a symbolic link, use MKLINK command line tool. MKLINK can be used to create a hard link or directory junction (junction point) too. Hard link is essentially giving another name or label to the objects, while NTFS directory junction point is used to redirect the whole folder to another folder as if it’s the original folder itself. Junction point is used extensively in Windows to provide support for old directory structures for user profiles (i.e Documents and Settings) to point to the new user folders located inside Users directory.

Syntax and Options of MKLINK

MKLINK [[/D] | [/H] | [/J]] Link Target

/D – Creates a directory symbolic link. Default to file symbolic link.
/H – Creates a hard link instead of a symbolic link.
/J – Creates a Directory Junction.
Link – Specifies the new symbolic link name.
Target – Specifies the path (relative or absolute) that the new link refers to.

Examples and Usages of MKLINK

Note: Only Administrators can use MKLINK to create symbolic links unless override by using secpol.msc, so you need to run Command Prompt with elevated privileges, or else you will get “You do not have sufficient privilege to perform this operation.” error.

To create symbolic link called foo to reference to c:\Windows\System32\notepad.exe:

C:\test>mklink foo c:\Windows\System32\notepad.exe

You will see the following result:

symbolic link created for foo <<===>> c:\Windows\System32\notepad.exe

If you type dir in commnd prompt, you will see the following listing:

 Volume in drive C has no label.
 Volume Serial Number is 2211-7428

 Directory of C:\test

04/14/2006  11:24 AM    <DIR>          .
04/14/2006  11:24 AM    <DIR>          ..
04/14/2006  11:24 AM    <SYMLINK>      foo [c:\Windows\system32\notepad.exe]
               1 File(s)              0 bytes
               2 Dir(s)  69,238,722,560 bytes free

To create symbolic link to a folder, simply use /D switch, or /J for junction point (directory junction is not available for remote network location):

C:\test>mklink /d bar c:\Windows
symbolic link created for bar <<===>> c:\Windows

Results of dir command:

 Volume in drive C has no label.
 Volume Serial Number is 2211-7428

 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]
               1 File(s)              0 bytes
               3 Dir(s)  69,238,722,560 bytes free

MKLINK cannot be used to delete symbolic link. To remove a symbolic link, simply delete them as if you’re removing a normal file. For example, to delete the foo symbolic link created above, enter the following command:

C:\test>del foo

To remove the bar symbolic link to a folder created above, use the following command:

C:\test>rd bar