MKLINK vs. Junction.exe

27,718

Solution 1

Comparison

Mark Russinovich's junction program was designed with a specific goal in mind: create (and delete) junction points. It was maintained through the years, but no new features were added so far. The latest version was released on July 4, 2016.

As for mklink, it's a built-in command available in Windows Vista and later. It can create hard links, junction points, and symbolic links. A specific delete function is not provided; you can simply use the del or rd commands, depending on whether the link points to a file or a directory, respectively.


A bit of history

Prior to Vista, Windows operating systems didn't provide a way to create junction points out of the box: you either had to get a copy of the official Resource Kit, use a third-party program, or write one yourself.

2000

The first version of the junction tool was released. Quoting the official website:

Windows 2000 and higher supports directory symbolic links, where a directory serves as a symbolic link to another directory on the computer. [...]

Unfortunately, Windows comes with no tools for creating junctions—you have to purchase the Win2K Resource Kit, which comes with the linkd program for creating junctions. I therefore decided to write my own junction-creating tool: Junction.

Source: Junction

2005-06

The mklink command was introduced with Windows Vista during the early beta phase.

It was available since the official Beta 1 shipped on July 27, 2005. Initially it could only create symbolic links and hard links; the ability to create junction points came later with the Community Technology Preview (CTP) released on December 19, 2005.

Apparently the command went entirely unnoticed until some time later in 2006, when it was first disclosed. Here's the earliest reference I was able to find:

You can create symbolic link in Windows Vista now.

C:\test>ver

Microsoft Windows [Version 6.0.5365]

C:\test>mklink
Creates a symbolic link.

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

Source: Symbolic link in Windows Vista

Also:

Malcolm [MSFT] (Expert):
Q: Is there a really easy way to make a symlink?
A: Open CMD, and type 'mklink'. This tool will allow you to create junctions, hardlinks and symbolic links.

Source: NTFS Beta Chat Transcript (July 12, 2006)


Additional information

A file or directory can contain a reparse point, which is a collection of user-defined data. The format of this data is understood by the application which stores the data, and a file system filter, which you install to interpret the data and process the file.

For example, reparse points are used to implement NTFS file system links and the Microsoft Remote Storage Server (RSS).

Source: Reparse Points

There are three types of file links supported in the NTFS file system: hard links, junctions, and symbolic links.

Source: Hard Links and Junctions

Hard links

A hard link is the file system representation of a file by which more than one path references a single file in the same volume. [...] Any changes to that file are instantly visible to applications that access it through the hard links that reference it. However, the directory entry size and attribute information is updated only for the link through which the change was made.

Source: Hard Links and Junctions

Junctions

A junction (also called a soft link) differs from a hard link in that the storage objects it references are separate directories, and a junction can link directories located on different local volumes on the same computer.

Source: Hard Links and Junctions

Junction points can only link to directories on a local volume; junction points to remote shares are unsupported.

Source: NTFS junction point

Symbolic links

A symbolic link is a file-system object that points to another file system object. The object being pointed to is called the target.

Symbolic links are transparent to users; the links appear as normal files or directories, and can be acted upon by the user or application in exactly the same manner.

Source: Symbolic Links

[Symbolic links] were introduced with the modifications made to the NTFS file system with Windows Vista, but available through filter drivers for Windows XP.

Unlike an NTFS junction point (available since Windows 2000), a symbolic link can also point to a file or remote SMB network path. While NTFS junction points support only absolute paths on local drives, the NTFS symbolic links allow linking using relative paths.

The default security settings in Windows Vista/Windows 7 disallow non-elevated administrators and all non-administrators from creating symbolic links.

Source: NTFS symbolic link

Further reading

Solution 2

As already mentioned in the comments, junction.exe came out before Vista/Winserver 2008, which came with the mklink command.

Therefore there is no point in using it on Vista onwards. Versions of Windows older than Vista are no longer supported anyway.

Also, junction.exe does not support NTFS Symbolic Links (only NTFS Junctions), which were introduced with Vista/WinServer 2008 and the mlink command.

Share:
27,718

Related videos on Youtube

abelenky
Author by

abelenky

I've worked in C, C++, C#, ASP.net, Python and touched on many other languages. Graduated from MIT in '96 in Computer Science, active in politics. At various times, worked for Microsoft, Tegic, AOL, Melodeo, Sagem-Morpho, and (secret project). Currently a Senior Engineer at Spear Power.

Updated on September 18, 2022

Comments

  • abelenky
    abelenky almost 2 years

    SysInternals has a program junction.exe that creates Junctions (aka. reparse points, aka. symlinks) in Windows.

    However, Windows also comes with a mklink which seems to do the same thing.

    Is there a significant difference?

    I tend to believe that if SysInternals has their own program, they saw a deficiency in the standard MKLink program.

    • abelenky
      abelenky about 10 years
      Oops! I missed that. It does appear that Junction pre-dates mklink. Thanks.
  • Naidim
    Naidim about 10 years
    (referring to Hard Links, to clarify)
  • sshow
    sshow about 10 years
    Pure quality answer.
  • kbolino
    kbolino over 8 years
    NB: There are "file" symbolic links (made by plain mklink regardless of the target type) and there are "directory" symbolic links (made by mklink /d). It's best to create the right type of link for the target.
  • Adam Plocher
    Adam Plocher almost 7 years
    I'm curious why junction.exe got updated in 2016 and why do they continue to ship it with SysInternals? Are they against depecration? Come to think of it, yes they are... Probably half those tools have sufficient replacements in Windows. Excellent detailed answer.