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

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.

/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.

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: 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


Or you might like these sexy wallpaper, tweaks and themes:

Written by oliversk Monday, January 3rd, 2011

Was it helpful? Please bookmark it and spread the word

delicious   facebook   google   twitter  

You love Windows, Gaming and everything digital? Great, we too! We have thousands of great Windows 7 themes, registry tweaks, tutorials, so please use our search box if you look for anything specific. If you have some awesome desktop themes, tips or want to write for us, then drop us a mail: win7themes at googlemail.com

7 Responses to Mklink command: Create symbolic links in Windows 7

  1. adam said:

    Does not work.

  2. sOliver said:

    adam, I can’t help you if you don’t post an error message. Mklink is very easy to use and I suppose your forgot the quotations or you simply copy and pasted, which will not work, because you need to manually type the quotation marks.

  3. branko said:

    i create symbolic link with mklink on desktop, when i try to doubleclick it to open a file the link was created for, i receive an error.

  4. Klaian said:

    Do both drive need the same file system in order to use this?

  5. Aasim Ansari said:

    Hi,

    I am trying junction link. But I am getting error-
    Cannot create a file when that file aready exists.

    What could be the possible cause of this error. Both my source and destination are folders.

  6. Noteworker said:

    This worked like a CHARM! Thanks SO much for posting it! Saved me at least 4GB on my SSD…

    Just to clarify to those who might not realize:
    The file you wish to point to on your other drive (D:, E:, F:, etc.) MUST NOT EXIST yet on the C: drive before you create it through mklink.

    For example, if you wish to point from
    “C:\Program Files (x86)\Adobe\Adobe Premiere Elements 9\Movie Themes”

    to

    “D:\Adobe\Adobe Premiere Elements 9\Movie Themes”

    then you need to DELETE the “Movie Themes” folder on the C: drive first before mklink can create a Junction there for it.

    A simple concept, I know, but if one doesn’t completely grasp what mklink is actually doing, then it’s an easy concept to miss…

    Cheers!

  7. Wes said:

    I’m trying to make a link to my linux webhosting server: I used a webdisk program to assign a drive letter on my local PC that points to the Server Folder and that works fine but my backup program won’t recognize that drive letter as “local” So i thought mklink /D would allow the backup program to see this folder as “local” and allow me to backup from my home pc to the server. My command is not working though:

    Web Drive is much like a mapped network drive and the location i want to link is Z:\Art1 and i want to link to C:\Art

    mklink /D “Z:\Art1″ “C:\Art” and i keep getting “cannot find the path specified”.
    Please help

    Wes

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>