The Complete Guide to Creating Symbolic Links (aka Symlinks) on Windows

Key Takeaways

  • Symbolic links are advanced shortcuts in Windows 11 and Windows 10 that can point to a file or folder, redirecting applications to access them as if they were in a different location.
  • There are two types of symbolic links: soft links, which redirect to the location where files are stored, and hard links, which make it appear as though the file or folder exists at the location of the symbolic link.
  • Symbolic links can be created using the mklink command in Command Prompt, with different options for creating symbolic links to files or directories. Alternatively, you can use the Link Shell Extension, a graphical tool, to create symbolic links with more options.


Windows 11 and Windows 10 both support symbolic links — also known as symlinks — that point to a file or folder on your system. You can create them using the Command Prompt or a third-party tool called Link Shell Extension.


Symbolic links are basically advanced shortcuts. Create a symbolic link to an individual file or folder, and that link will appear to be the same as the file or folder to Windows — even though it’s just a link pointing at the file or folder.

For example, let’s say you have a program that needs its files at C:\Program. You’d really like to store this directory at D:\Stuff, but the program requires that its files be at C:\Program. You could move the original directory from C:\Program to D:\Stuff, and then create a symbolic link at C:\Program pointing to D:\Stuff. When you relaunch the program, it will try to access its directory at C:\Program. Windows will automatically redirect it to D:\Stuff, and everything will just work as if it were in C:\Program.

This trick can be used for all sorts of things, including syncing any folder with programs like Dropbox, Google Drive, and OneDrive.

There are two type of symbolic links: Hard and soft. Soft symbolic links work similarly to a standard shortcut. When you open a soft link to a folder, you will be redirected to the folder where the files are stored. However, a hard link makes it appear as though the file or folder actually exists at the location of the symbolic link, and your applications won’t know any better. That makes hard symbolic links more useful in most situations.

Note that Windows doesn’t actually use the terms “hard link” and “soft link”. Instead, it uses the terms “hard link” and “symbolic link”. In the Windows documentation, a “symbolic link” is the same thing as a “soft link”. However, the mklink command can create both hard links (known as “hard links” in Windows) and soft links (known as “symbolic links” in Windows).

You can create symbolic links using the mklink command in a Command Prompt window as Administrator or as a regular user. To do this without an Administrator Command Prompt window, you must first enable Developer Mode from Settings > Update & Security > For Developers.

To open Command Prompt as admin, click the Start button, search “cmd” or “Command Prompt,” then select “Run as Administrator”.

Windows 11 doesn’t require administrative privileges to create symbolic links.

Click

Without any extra options, mklink creates a symbolic link to a file. The below command creates a symbolic, or “soft”, link at Link pointing to the file Target :

mklink Link Target

Use /D when you want to create a soft link pointing to a directory. like so:

mklink /D Link Target

Use /H when you want to create a hard link pointing to a file:

mklink /H Link Target

Use /J to create a hard link pointing to a directory, also known as a directory junction:

mklink /J Link Target

Command Prompt window with the arguments for mklink.

So, for example, if you wanted to create a directory junction (a hard link to a folder) at “C:\LinkToFolder” that pointed to “C:\Users\Name\OriginalFolder,” you’d run the following command:

mklink /J C:\LinkToFolder C:\Users\Name\OriginalFolder

You’ll need to put quotation marks around paths with spaces. For example, if the folders are instead named “C:\Link To Folder” and “C:\Users\Name\Original Folder,” you’d use the following command instead:

mklink /J "C:\Link To Folder" "C:\Users\Name\Original Folder"

Command Prompt window with successful hard symbolic link created between "C:\LinktoFolder" and C:\Users\Name\OriginalFolder

If you see the message “You do not have sufficient privilege to perform this operation.”, you need to launch the Command Prompt as Administrator before running the command.

If you’re like to do this with a graphical tool, download Link Shell Extension. Be sure to download the appropriate prerequisite package before the tool itself — both are linked to on the tool’s download page.

Once it’s installed, locate the file or folder you want to create a link to, right-click it, and select “Pick Link Source” in the menu.

Right-click target folder in Windows Explorer, then click "Pick Link Source" in the right-click context menu.

You can then right-click inside a different folder, point to the “Drop As” menu and select “Hardlink” to create a hard link to a file, “Junction” to create a hard link to a directory, or “Symbolic Link” to create a soft link to a file or directory.

Right-click in target folder and select "Junction" to create a hard link in that location.

To get rid of a symbolic link, you can simply delete it like you would any other file or directory. Just be careful to delete the link itself rather than the file or directory it’s linking to.

Right-click the symbolic link and click "Delete" to remove a link.

That is a major advantage of a symbolic link — you can freely delete the symbolic link whenever you want without worrying about the associated files or folders.

Source

      Guidantech
      Logo
      Shopping cart