Symbolic Links, Hard Links and Directory Junctions in Windows 10

In Windows 10, you can using symbolic links to easily redirect one folder to another location. Symbolic links are widely used in the operating system for its own files and folders. Using symbolic links, you can save your disk space and make your data accessible from various file system locations without physically moving your data.
Symbolic links can be pretty useful in many situations. For example, recently I added an SSD drive to my computer and installed Windows there. All my portable apps remained in the D:\portable folder and many of them were configured to work with the folder D:\documents. The problem was that before I added this new SSD, the path to folders was C:\portable and C:\documents.

By symlinking these two folders I got everything working within a few seconds. I created symbolic links named c:\portable and c:\documents without moving a single file or folder. Another interesting thing is that if I move my symbolic links to some other location, for example, to the E: drive, they continue to work and will point to my folders on the D: drive.

Here is how symbolic links can be created.

For symbolic link management, Windows offers you many ways.

The most famous tool is mklink. It has the following syntax (mklink /?):

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

/D - Creates a directory symbolic link. Default is a 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.

Now you may wonder what is the difference between a directory symbolic link and a directory junction.

What is the difference between a directory symbolic link and a directory junction
A Directory Junction is an older type of symbolic link, which does not support UNC paths (network paths that begin with \\) and relative paths. Directory junctions are supported in Windows 2000 and later NT-based Windows systems. A directory symbolic link on the other hand also supports UNC and relative paths. However, they require at least Windows Vista. So, in most cases today, the directory symbolic link is the preferred option.

What is the difference between a hard link and a symbolic link
A hard link can be created only for files, not folders. You cannot create a hard link for directories. So, it has more limitations than a Directory Junction and also does not support UNC paths.

How to see if a file or a folder is a symbolic link
Let's create all three types of symbolic links and see how they will be displayed in the operating system.
I will create the folder Winaero on my desktop and the text file Winaero.txt in the same location.
Then, I will create a new symbolic link and a new Directory Junction for the folder and the text file.

The mklink command requires Administrator privileges, so you need to run it from an elevated command prompt.

The following command will create a new directory symbolic link:

mklink /d "c:\users\winaero\desktop\directory symbolic link" "c:\users\winaero\desktop\winaero"

A directory symbolic link can be visually identified by the shortcut overlay icon added to its main icon:

Additionally, when you have enabled the "Attributes" column in the Details view of File Explorer, you will see the "L" attribute which indicates that it is a symbolic link.

Now, let's create a new directory junction for the Winaero folder, as follows:

mklink /j "c:\users\winaero\desktop\directory junction" "c:\users\winaero\desktop\winaero"

It has no visual difference from a directory symbolic link in File Explorer, so you cannot tell if it is a directory junction or a directory symbolic link:

The only way to find the type of the link is to use the console dir command. Open a new command prompt window in the folder which contains your link and run the dir command. See the output:

Now, let's create a symbolic link for the text file I created. The command is as follows:

mklink "c:\users\winaero\desktop\file symbolic link.txt" "c:\users\winaero\desktop\winaero.txt"

Again, it is not visually different from a regular shortcut file, besides the attributes column value and the "symlink" item type:

The situation is different for hard links. Let's create one:

mklink /h "c:\users\winaero\desktop\file hard link.txt" "c:\users\winaero\desktop\winaero.txt"

The hard link has no visual difference from a regular file when displayed in File Explorer:

The only way to ensure that the file is a hard link is to use another console utility, fsutil.
Run it as follows :

fsutil hardlink list "file hard link.txt"

The mentioned command shows all hardlinked files:

You cannot see if a file is a hard link easily because Explorer out of the box gives no such indication. They behave like regular files in a dir command's output or in File Explorer.

However, hard links are still links to other files. They do not duplicate the target file's content and do not take redundant disk space.

In Windows Vista and later, directory junctions are used to link older file folder paths like C:\Documents and Settings to newer paths like C:\Users. Symbolic links are also used to redirect C:\Users\All Users to C:\ProgramData.

Starting with Windows Vista, hard links are also widely utilized by Windows and its Servicing mechanism. Many system files are hard links to files inside the Windows Component Store folder. If you run the command fsutil hardlink list for explorer.exe, notepad.exe or regedit.exe, you can see this yourself!

The WinSxS folder stores various system files, which are linked via hard links to the files located in the folders C:\Windows, C:\Windows\System32 and other system folders. When operating system updates are installed, the files inside WinSxS are updated and hard linked to system locations again.

That's it. Now you know everything you need to know about symbolic links in Windows 10. Using this information, you can resolve issues with paths when you add a new disk drive in your computer, or move some folder but still need it to be accessible via its previous path. Feel free to leave a comment if you have a question or have something to add.

Now, see how to create symbolic links with PowerShell.

Support us

Winaero greatly relies on your support. You can help the site keep bringing you interesting and useful content and software by using these options:

If you like this article, please share it using the buttons below. It won't take a lot from you, but it will help us grow. Thanks for your support!

Author: Sergey Tkachenko

Sergey Tkachenko is a software developer who started Winaero back in 2011. On this blog, Sergey is writing about everything connected to Microsoft, Windows and popular software. Follow him on Telegram, Twitter, and YouTube.

12 thoughts on “Symbolic Links, Hard Links and Directory Junctions in Windows 10”

  1. Thanks, Sergey, for useful article. Want to share, I’m using Link Shell Extension to create links. It integrates into system and provides different overlays for symlinks, hard links and junctions.

    1. Link Shell Extension is deserving a separate review, which we had planned for today :)
      Stay tuned.

  2. There is no information in the post, how one cam delete sym/hard links properly, without deleting original files.

    1. Also use of FAT32 and NTFS is not fully covered. On WinXP I use Junction by Mark Russinovich which works really good.

      Otherwise good article.

      1. Windows built-in tools do not support FAT32 symbolic links.
        I am pretty sure that FAT32 does not support symlinks by design. Nor hard links or symbolic links.

        On WinXP I use Junction

        The article title says “In Windows 10”.

    2. When you delete a symlink, the original file remain unaffected.
      Unless you are using the del /s console command, which is designed to delete the linked content intentionally

  3. Sergey, very good article! Thank you!

    It would be excellent to add the function of creating symbolic links to WinaeroTweaker. Is it possible, or what do you thinks about this?

    1. Well, it is possible I think.
      I can add a GUI wrapper for this feature.
      However, I don’t think that many users will use it.
      I added it to my product back log.

  4. Use Linkshell Extension to create Links. It adds a tab in properties, showing you the enumerations and adds an Entry in the Context Menu to Pick a Source and Drop as some kind of link at the location you want it. Makes life a whole lot better.

Leave a Reply

Your email address will not be published.

Exit mobile version
Using Telegram? Subscribe to the blog channel!
Hello. Add your message here.