Mklink command: Create symbolic links in Windows 7

I frequently use symbolic links on Linux, but I rarely use them on Windows 7. However, creating symlinks in Windows 7 is really easy via mklink. Here’s the syntax and a simple example.

Mklink Command for Symbolic Links

Tip: When using the mklink command, never forget the quotes. Also, deleting the symlinks via the Windows Explorer works, you’re not deleting the actual folder

Mklink Example

MKlink Example

Enter mklink /J "C:\Program Files (x86)\Steam\steamapps\common\audiosurf" "D:\audiosurf"

In this example I create a directory junction in C:\Program Files (x86)\Steam\audiosurf that points to the actual game folder D:\audiosurf

Mklink Command Syntax

MKLINK has 3 options /D, /H and /J. You also need to specify the path to the new symbolic link and the path to the original file or directory.

The Syntax:
/D – used to create symbolic links for directories (d for directory)
/H – used to create hard links (h for hard link)
/J – used to create directory junction (j for junction

What Are Hard Links

Hard links can be defined as “real” links to a file. Windows will treat that link as if it was the original file or directory
Soft links are only shortcuts to a directory, they will not be treated as the real file

What Are Directory Junctions?

A directory junction is basically a hard link (see above) to a directory. We will use this in our example.

When To Use Junction Points vs. Symlinks

Most hard links on Windows will be junction points, but certain programs may only support Symlinks. According to TechNet, symlinks were first introduced for better Linux compatibility (although I fail to see how it is compatible at all). In any case, it is a good idea to first create a junction point and then if that does not work out, create a symlink. Symlinks are also great for relative file links e.g. ..\..\..\..\my-nested-folder

Mklink: Syntax Incorrect

A common mistake of people who are new to creating symlinks is that they forget to add the quotation marks. If you enter a long path and you don’t add the quotation marks to the paths it will output a syntax error, because of the many spaces.

You can either cd to a directory and use relative paths or you can simply add the quotation marks like

mklink /J "path" "path"

If you have any questions how to use mklink or if you need further examples to fully understand it, you may post your request below.

Change Steam Download Directory via MKLINK

Read our tutorial: How to change Steam download directory via symlinks

Twitter.png Facebook.png GooglePlus.png Pinterest.png LinkedIn.png Tumblr.png Email.png
3 of 5 0 (60%) 2 votes
- Cheers!

Tags: ,