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

3 of 5 0 (60%) 2 votes
- Cheers!

Tags: ,


Written by:
Oliver is the founder and lead editor of this site. He is interested in finding new ways to break Windows, find common errors and help others to fix them. Aside from that, he loves to fully customize systems with Rainmeter and Dreamscene, find out more about ancient civilizations like the Chachapoya, sharpen his digital photography skills and create software with a small group of selected developers. If you would like to connect with him to discuss anything, send him a mail!

Learn More About.Me

Follow me on Twitter for daily updates: Twitter Follower

Contact The Author:
support@windows7themes.net Get Free Help.png

Connect With Our Site:

facebook google twitter


Need help? Ask a question at our QA site, click the red button to get started:

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

  1. Orange Community Approved Comment:
    adam said:

    Does not work.

  2. Orange Community Approved Comment:
    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. Orange Community Approved Comment:
    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. Orange Community Approved Comment:
    Klaian said:

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

  5. Orange Community Approved Comment:
    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. Orange Community Approved Comment:
    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. Orange Community Approved Comment:
    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

  8. Orange Community Approved Comment:
    M Young said:

    Hi

    I am getting the following error message:
    “The syntax of the command is incorrect.”
    for the following command.
    mklink /d “C:\Program Files (x86)\Origin Games” “P:\Origin Games”

    P: is a partition on the second physical drive.

    Please help.
    Mike

  9. Orange Community Approved Comment:
    Alex said:

    Hi, i try to link FileZilla to my Dropbox directory like this:

    mklink “C:\Users\Alexander Herbert\AppData\Roaming\FileZilla\sitemanager.xml” “C:\Users\Alexander Herbert\Dropbox\Firma\Einstellungen\sitemanager.xml”

    and get the syntax error, no number or more information. Could you help to figure this out?

    Thanks

  10. Orange Community Approved Comment:
    g said:

    thank you, very clear and helpful

  11. Orange Community Approved Comment:
    Martin said:

    Hi,

    I am trying to link my iTunes backup folder on my 60Gb “C” drive partition to my much large “D” drive partition.

    My iTunes “C” drive location is:
    C:\Users\webster\AppData\Roaming\Apple Computer

    My target location is:
    D:\Users\webster\AppData\Roaming\Apple Computer\MobileSync

    I have deleted the MobileSync folder from the “C” drive as mentioned above (i.e delete source folder)

    From the CMD prompt I changed loaction to Apple Computer source location by:

    cd C:\Users\webster\AppData\Roaming\Apple Computer

    When trying to create the symbolic directory link using:

    MKlink /D “MobileSync” “D:\Users\webster\AppData\Roaming\Apple Computer\MobileSync”

    I get an error:

    “The syntax of the command is incorrect”

    Would you please be kind enough to guide me on where I am going wrong, I am sure it will be something simple. I have tried with / without quotation marks, used the full source location, but still no luck.

    The reason for doing this is to redirect my iTunes backups to my “D” drive as my “C” drive is short on space.

    Many thanks for all help given.

    Martin

  12. Orange Community Approved Comment:
    AMgold said:

    qSays I dont have proper permissions. Is there anything like the sudo command in linux for windows?

  13. Orange Community Approved Comment:
    oliversk said:

    AMgold, no there is no sudo per se, you need to open an elevated command prompt to run admin functions

    http://windows7themes.net/how-to-open-elevated-command-prompt-in-windows-7.html

  14. Orange Community Approved Comment:
    Pank said:

    great thing, helped me a lot to play music that was not in the target folder but referred to on an old playlist. Other articles misled. Thanks

  15. Orange Community Approved Comment:
    James said:

    Hello, I’m trying to use the mklink command to transfer from the default location for backup of Apple mobile devices to another drive. I believe I understand the directions for doing this, but when I open the command prompt it already starts with the “C:\Users\(username. (Which I’m unable to delete) So, I’m unable to enter the start of the command: \mklink /J “.

  16. Orange Community Approved Comment:
    retroguy said:

    This is an excellent tutorial. Thanks for sharing. I’ve just moved my ‘outlook files’ from my C drive on a small SSD to my 1TB data drive.

    This saved me 4GB of space. Awesome.

    mklink /J “C:\Users\USERNAME\Documents\Outlook Files” “E:\My Documents\Outlook Files”

    Just change USERNAME and destination link and you are good to go

  17. Orange Community Approved Comment:
    Steve King said:

    I made a link that I want to delete and several have said to delete the file made my that mklink /J but don’t say where that file is or what it might be named. Any ideas about this? Do I have to rmdir the directory it is linked to? I am on Win 7 Pro, very new to it so I am having trouble moving my Public folders to a larger second internal drive. I got Pics, Music and Video to work on the PC, haven’t tried the network users, but didn’t get to Public\Documents. I screwed up somewhere…

  18. Orange Community Approved Comment:
    Jeffrey S. said:

    Will not Work. Not only does it give me an error when I try to Open the Junction, but the game where I had saves in can’t find ‘em!

  19. Orange Community Approved Comment:
    Oliver Krautscheid said:

    Jeffrey, does it say “Junction created”? Also, instead of using junctions try mklink /d to create a symlink instead, maybe your game does not recognize junction points

    Not all games may support them.

    There is a difference between symbolic links /D and junction points /J – when in doubt, try both. NTFS junction points is what you would want to try first, only if that not works try a symlink. Most of the default links on Windows 7 are junction points

    Symlinks are better used for absolute and relative file links (relative from a certain directy e.g. ..\..\I-a-m-here\; absolute: C:\Windows)

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>

Current day month ye@r *