Windows File Junctions, Symbolic Links and Hard Links

For a long time Linux and Unix have had the marvellous ability of allowing user created links on their file systems. These links are file and folder pointers that are sorted and registered by the operating system file partition. But unlike the more common Microsoft Windows shortcut, programs that encounter user created links will treat them as the source file or folder.

This is advantageous for a number of reasons especially if you use multiple partitions on your computer. I for example keep all my work related files on a separate partition labelled as the W: drive. This allows me to optimise searches and backups as well as keeping the partition more secure from potential problems.

Part of my work involves web development and for testing often the files I am working with need to be located within a web server’s root directory. But this can be problematic if the server application is installed on the C: drive. So a hard link is useful as I can create a pointer from the server root directory and target it to the folder containing the project files on the W: work drive. Once the project is completed the hard link can be removed which would sever the link to the testing web server without the need to move any files.

The Windows NTFS file system has supported some form of file and directory pointing since Windows 2000. But this article will only focus on the implementation used in Windows 6 (Vista) through to Windows 10.

Shortcuts, symbolic links, hard links & junctions?!

shortcut is a file that points to another file. It is an antiquated pointing system from the Windows 95 era that many programs do not recognise. Shortcuts do not only use up space on the hard drive, they also break and linger behind after the target has been deleted, renamed or moved.

A symbolic link is like a shortcut but instead of being saved as a file it is registered to the hard drive partition. It does not use any disk space and all programs recognise both the link and the target. A symbolic link can point to any file or folder either locally on the computer or over a network using a SMB path.

A file hard link is a little different and can not be used over multiple partitions meaning you can not have a link on drive C: pointing to a file on drive D:. A file hard link points to and duplicates a target as a mirrored copy but the copy does not use any additional space on the hard drive partition. So 2 hard links that mirrored a 1 GB file would  in total only use 1 GB on the partition rather than 3 GB. Importantly if either the hard links or the target are deleted the other links retain the data. Changes to the content of either the target or the links automatically propagate to all other items.

A junction behaves like a hard link for directories but unlike file hard links you can create junctions that span multiple partitions. Again a directory junction and its content is stored on the hard drive partition but they do not use any additional space. Any changes to the content within either the target or the links will automatically propagate except where the target directory is deleted or renamed. In that case all links that point to the target will break and linger on the partition.

Creating links

Microsoft Windows uses the command line program mklink to create links [1]. It has 3 slash (/) parameters and requires both a link name and target. Multiple slash parameters cannot be used together.

mklink /D /H /J [LINK NAME] [TARGET]

Supplying no slash parameters creates file symbolic link which is a pointer to a file.

/D parameter creates a directory symbolic link which is a pointer to a directory.

/H parameter creates a file hard link and is best used in situations where you need multiple mirrors of a file.

/J parameter creates a directory junction which is a directory link that mirrors a the target directory over the same or on a different hard drive partition.


mklink /J Win10 C:\Windows

This example would create a directory junction named Win10 that linked to the directory C:\Windows.

mklink /D C:\User\Ben\Desktop\Downloads C:\User\Ben\Downloads

Creates a symbolic link on my Desktop to link to my Downloads directory. But unlike a shortcut I can right-click on the generated icon to view the target’s properties and even apply folder attributes.

Shortcut and symbolic link
The general properties of both a shortcut and a symbolic link to the Downloads folder

Below is a screen capture of the 4 different types of links in use on Windows.

  • The blue is a symbolic link to a file
  • While the red is a directory junction
  • The yellow is a hard file link that does not consume any additional hard drive space
  • The green is a symbolic link to a directory
windows symbolic links
Examples of Window’s symbolic link types


[1] Windows XP and 2000 did not use mklink but instead used 3rd party tools such as linkd or junction.


57 thoughts on “Windows File Junctions, Symbolic Links and Hard Links

  1. Hi,

    Your article has helped me clarify a lot of things.
    There is one question that I don’t really know: What is the difference between a “directory symbolic link” and a “junction”?

    Thanks in advance!

    1. It is a little complicated but originally Windows 2000/XP only supported directory junctions, but these were not compatible with other file systems, files or network shares. So with Windows Vista Microsoft added file and directory symbolic links. This not only allowed connection with remote SMB network paths ( //SERVER/Directory/ ) but they were also more compatible with the POSIX operating-system standard, aka Linux/Unix links.

      Microsoft had to keep their older Junction system within NTFS for backwards compatibility with Windows 2000/XP. But if you are not using these systems, then you are probably better off sticking with symbolic links.

        1. Hi Maricon thanks for the follow up. Symbolic links were introduced into Vista to aid in interoperability between Windows and POSIX-compatible machines such as Unix, OS-X and Linux.

          “Symbolic links are designed to aid in migration and application compatibility with UNIX operating systems. Microsoft has implemented its symbolic links to function just like UNIX links.”

          You are correct in that a NTFS junction is technically a soft-link. On an Windows NTFS partition a junction behaves much like a NTFS hard link but it links directories rather than files. When writing this blog entry a number of years ago I tried to simplify the terminology to make it less confusing for the uninitiated.

  2. Ok… great your article has helped me out quite abit. but how do i get a report of all the existing junction links? Am i correct in assuming that the documents and settings folder is actually a directory junction hard link to the users folder?


  3. one very important information is missing. directory junction links can be moved to another directory and they still point to the right destination. when you however move a symbolic link, it’s no more valid.

    1. My reply comment is only referring to Windows 7, but I imagine it would be the same in Windows Vista. If you move a symbolic link or a directory junction into another folder, both links maintain the correct pointer. If you rename or move the pointer, both links do not update.

  4. Sorry to dredge up an old thread, but I found this very useful in understanding the difference between a Junction and a Symbolic Link. I was always curious as to what Symbol Links brought to the table that were new in any way, so thanks for the article.

    I would like to clarify one point, specifically related to the point “stone” was making. There is a difference between how Junctions, Symbolic Links and Volume Mountpoints are treated when performing file system operations such as move/copy etc. If you create a Symbolic Link, and you then move that link it is much the same as a shortcut in that it just moves the link itself, no actual data is moved/copied.

    However, if you move a Junction or Volume Mountpoint, a new folder is created at the move destination point and the contents of the original data folder is physically moved from its source location to the new move location. The Junction or Volume Mountpoint remains where it was, and the source folder remains intact (it just becomes empty).

    So there are differences in the way Windows treats the types of links. Try it out and you will see what I mean.

    I have tested this on Windows 7, I do not have Vista.

  5. After a clean install of my Vista 32-bit OS, I am taking the opportunity to redirect my user folders away from the C: drive. It is a process fraught with frustration due to duplication of folders and inability to delete the empty original folders. Although there are plenty of helpful suggestions out there for complex registry edits, this seems a cumbersome and untidy – not to mention risky – approach. So a MKLINK /J redirection from source to my desired partition would be an elegant and convenient ‘solution’, if I can make it work.

    But it’s not working at the moment! From the cmd prompt (regardless of which drive or directory I start from), when I enter I receive error message: ‘Cannot create a file when that file already exists.’

    Could you please advise whether (a) it is possible to create a junction across partitions? And (b) if so, what is the correct syntax?

    Many thanks in anticipation.

  6. Sorry – that should read:

    From the cmd prompt (regardless of which drive or directory I start from), when I enter

    “mklink /j c:\users e:\users”

    I receive error message: ‘Cannot create a file when that file already exists.’

    Could you please advise whether (a) it is possible to create a junction across partitions? And (b) if so, what is the correct syntax?

    Many thanks in anticipation.

    1. You syntax directory / target syntax looks to be wrong way around, you need do LINK NAME then TARGET. Your example is trying to join E:\users and create the junction at c:\users. But that will not work because you have an existing directory already there.

      Try “mklink /j e:\users c:\users” 🙂

  7. Okay, everyone seems to have skipped over this so I’m wondering if I’m just not familiar with it because I’m not as used to Windows as I am Linux…

    How did you get the color support in your terminal? Is it a terminal replacement of some sort or some special hack or just some image editing trick?

    Other than that; very decent article. You may wish to know, however, that on most UNIX/Linux systems a symbolic link does, in fact, take up space though it is not much. It is created as a special independent file which takes up a minimal amount of space and acts as a pointer to a different location where the target file may be found. Hard links share the target file’s inode and, as such, don’t take extra space in the filesystem itself. As well, because POSIX-compliant systems follow the ‘everything is a file’ philosophy, there is no distinction between a ‘file’ link and a ‘directory’ link. So one needn’t worry about figuring out how to create a ‘directory junction’ in *nix.

    1. Hi GoSteen unfortunately that screenshot is not a colour terminal rather it involved some post image editing to simply highlight the different types of links. As a Linux user yourself I would highly recommend using Cygwin and combine it with Mintty for a decent terminal for Windows. It also gives you a slew of ported Linux shell apps, full access to your ntfs partitions and most importantly colour.

    1. I did a quick test on Windows 7 and managed to create a symbolic directory link to a shared directory on my local network.

      I ran command prompt as an Administrator and then ran the following

      mklink /d testlink \\NAS\my_shared_folder_name

      I could then cd \testlink and that would take me to the folder stored on the NAS. I hope that helps.

  8. My computer has an SSD (boot drive) and an HDD (data drive). I have relocated the Documents folder to the HDD, but would like for one small folder (which needs to be be in the Documents folder for some program to work) to be stored on the SSD for decreased latency. If I use a directory junction, will the HDD need to be read to reach the link in the file system? Is there an interim case where the file system is in some chip in the HDD assembly at the end of the SATA cable, but not on the disk that has to spin up?

    1. Sorry for the slow reply Luke I must have mistakenly missed your question.

      I am pretty sure that the junction data will be contained within the NTFS file system on the HDD rather than your target SSD drive. So the HDD containing this junction the target details will probably need to be read at least once. I don’t know if after it has been read for the first time if Windows remembers the target and keeps the information in the system memory.

    1. I have never done it myself nor seen it written about. The System Volume Information directory is specifically used to house Windows System Restore files and databases. Considering the purpose of System Restore is to have a ready fail-safe recovery point in case your operating system, software or some drivers go haywire to be on the cautious side it is probably best not to play around with this. If you don’t need this extra protection and wish to save some disk space you could simply turn System Restore off.

  9. Hello, I have done this a few months ago in windows 7 without issues.
    But currently I am getting an error in windows, as if the junction link is not working.
    When trying to login i get “The user profile service service failed the logon. User profile can not be loaded.”

    E = SSD
    D = HHD
    (as shown from disk part)

    robocopy /copyall /mir /xj E:\Users D:\User
    (no errors, takes about 15secs)

    rename e:\users e:\users.bak (also note i have renamed the folder to something like TESTING) just in case the .bak was confuisng it)

    mklink /J E:\Users D:\Users

    Do a few tests, If i go to E:\users and create a folder, then go to D:\users i see it; all looks good. And still same issue.
    I have done this about 10times to make sure im not being retarded.

    One fishy thing that i have seen, is if i use rmdir e:\users (deleting the junction), then the d:\users should be deleted, but its NOT! It is staying there…

    Anything that i am doing wrong? I swear this is what i did like 6months ago with two normal HHDs…

    1. Well I don’t know if this is a typo in the comment … but you are missing the trailing S on D:\User

      robocopy /copyall /mir /xj E:\Users D:\User

      But your symlink is pointing to D:\Users

      mklink /J E:\Users D:\Users

  10. Thank you. I have been searching for 4 hours now just so I could fully understand the difference between SymLinks and hard links. You gave the simplest explanation but gave it enough clarity. Now I can sleep. 🙂

    Oh, but wait. I do have a question. Is there any way to customize SymLinks so they’ll look distinguishable from the normal shortcut?

    1. In the command prompt there is a visual difference between a shortcut and a symbolic link. The shortcut will always have an file name extension “.lnk” and take up 1+kB while the symlink will not show any file size and instead list “SYMLINK”.

      On the Explorer/Desktop side of things I haven’t found away to visually distinguish symlink icons from those of shortcuts. I don’t think you can as when you open the properties of either a shortcut or a symlink icon they both have a “shortcut” tab. So I think for Windows Explorer and the Desktop it treats them as the same.

      In Windows Explorer if you switch into “list” view, a symlink will always be 0 bytes yet its “Item type” will always share the same as its target. So a symlink pointing to a PDF file will display “Adobe Acrobat Document” as the Item type. While a shortcut will be 2 kB and have an “Item type” of “shortcut”.

  11. Great write up. I am about to buy an SSD drive just for windows and make that my new C drive, then I want to make my new 1 TB HD (e: drive) for the Users, windows\temp, temp, program files, and program files x86 directories. Can you give me the run down of commands to type to use those directories on the hd? I want the SSD drive to basically be read only unless a windows update has to be performed. I want all the usual directories that change alot to be on the HD to limit the reads/writes on the SSD. Thanks in advance!

    1. That is a little out of the scope of this article. Basically you need to manually move all the directories over to your HD E: drive and then presumably create a directory symbolic link or a directory junction at their expected locations on the SSD C: drive. It is not something I have done as theses directories are critical Windows items. So I don’t know how the attempt would succeed as Windows has some inbuilt automatic restoration protections to stop users accidentally messing up their installations.

      It would probably be easiest and safer if you did the change on a fresh, clean install of Windows. If you are trying to do this on an existing install make sure you backup everything before attempting to move those directories!

      This semi-convoluted Life Hacker article might be of help.

  12. This is the best article about symbolic links, shortcuts, hardlinks and junctions I found so far, or at least the one I best understood. Thanks very much Ben.

    I would like to add something about the post where “Robert” mentioned If there was a way of listing all the symbolic link on a computer.

    Well one could use the command promt and enter:

    dir /s /al c:\

    Do this for all the drives you have Juncions, symbolic links and shortcuts. Let’s say you want a listing on your desktop about all the juncitons, symbolic links etc for c: and subfolders:

    dir /s /al c:\ > %userprofile%\desktop\junctions.txt

    1. Thanks for the positive feedback Ricardo I am glad this was useful for you. I just tried out your dir command for listing all links on a computer and it worked perfectly, nice work.

  13. Hi,
    After reading the previous posts, i still have a question about symlinks:
    let’s assume:
    HDD1 C: , D: , E: partitionned
    some users’s dirs on C: mklinked (/J option) to E: partition dirs

    then, because of run out of space on D: partition, i have to resize it (getting additional space from E:)
    are the links preservated after the whole process ?

    and more:
    Expanding D: partition to the rest of HDD1 and adding a new HDD as follow:
    HDD1 C: , D:
    HDD2 E:

    Tks in advance

    1. The links will remain unaffected unless you start deleting data off drive E:. Normally you will only be able to enlarge D: from unused space from drive E:. But your available free space on drive E: and for your symlink targets will be less.

  14. How do you get “DIR” to list JUNCTION, SYMLINK and SYMLINKD? And how do you get the lines in different colors? Did you color it manually or are they actually output like that? That would be really hand if it was possible somehow. Did you use DIR /A switch to get the SYMLINK to show up? In the command window it only says “DIR”.

    1. Hi, unfortunately Windows command line has no colour support. The screenshot was coloured manually for the purposes of this article. There are no additional switches needed with DIR to show the symlinks. If there is a link in the target directory, then DIR will display it.

  15. Hi Ben – this is an awesome article even for a non technical PC user as myself. I do have a question though. If all I am doing is moving my Users folder from C: to D: and wanting the result to be as pain free as possible when it comes to installing apps that may need to write to and refer to the Users folder, is it best to use /j or /d. Keeping in mind that I’d like it to also be pain free when copying, moving and deleting files within the Users folder. (Windows 8)
    Thanks again for a good article and any help you might provide.

    1. Hi Derek, I would recommend just using /d for all directory links unless you have a need otherwise.

      A word of warning for your task of relocating the Windows User folder, you will encounter problems. As the C:\User folder is classed as a critical directory. It is protected by Windows and your symlink to the D: drive will be replaced with a new C:\User directory after your next reboot.

      As a work around you can manually move the sub-directories within a C:\User\[user name] directory. Using Windows (file) Explorer if you right click on C:\User\Derek\Downloads, select the Properties option and then select the Location tab in the Downloads Properties dialogue. From there you can move the location of your downloads to a new drive or directory. It only works for Windows created public sub-directories such as Music, Pictures, Videos, Save Games etc, so it is far from a perfect solution.

      Otherwise if you’re brave you could try following these instructions.

  16. Wonderful article.

    Reading comments, a lot of people, like me, want to move their user folders to their non-SSD. The way I see it, you have two options: Don’t touch it (…PERHAPS link to pictures and music) OR reinstall windows. My system User folder is on my D: drive. Not linked, not in theory. Win 7 installed to C:, Users on D:. It’s not easy to do, it’s not fun, but it is absolutely what people are asking. It can only be done, as far as I know, on a fresh install of Windows.

    These instructions are for windows 8, but they remind me of the steps I took for Windows 7 so I’m guessing it’s pretty much the same. This may not give immediate solutions to people looking for immediate answers, but it might save people planning ahead, if such people exist. It’s just worth showing as an option.

  17. Great article. I have a curly question. I am trying to list the contents of a large hard drive, and used DIR /s piped to a file to grab details, then wrote a small program to parse the output into a regular form which I could import to Access or Excel.

    So far so good, except that the DIR got stuck, I think following the links and going around in circles until I killed it. Analysed the results and found lots of duplicated files and folder names, hence why I suspect links / junctions as the issue.

    Any way you know of to avoid traversing links with DIR /S, or an alternate means of listing all files and folders together with size and date, so I can do some rough and ready analysis on file age, size, types and duplicates? I’m working on a SOE without admin access, and can’t install utilities. I can run exe and scripts which are standalone in nature.

    (In case anyone suggests writing code, I was copying the output file to my notebook on USB key and writing the parsing program on the notebook.)

    1. Hi Simon,

      You could maybe try the Get-ChildItem -Recurse in Powershell and see if you have the same problem.

      Otherwise you could run ‘dir /AL /S D:’ to list only the Junctions/Symlinks etc on the disk drive and then manually delete the ones causing the problem. By the sounds of it you may have a junction or symlink pointing to itself and causing an endless loop?

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s