Symlink are shortcut files that refer to a physical file or folder located elsewhere. Symlinks act as virtual files or folders, which can be used to link with individual files or folders, making them appear as if they are stored in the folder with Symlinks, even though the Symlinks is only pointing to their real location.

It is important to understand that Symlinks are more than just Shortcuts that as a Windows user you already know. A shortcut file simply points to the desired file while Symlink will make it look like the linked file is actually there. Once you click on the Symlink, you will be directed to the actual file location.

A Symlink is build of a text string that is automatically interpreted and followed by the operating system as a path to another file or directory. This other file or directory is called the “target“. Symlink exists independent of its target. If a Symlink is deleted, its target remains unaffected. If a Symlink points to a target, and sometime later that target is moved, renamed or deleted, the symbolic link is not automatically updated or deleted, but continues to exist and still points to the old target. However, such Symlinks pointing to moved or non-existing targets are sometimes called broken, orphaned, dead, or dangling.

As Yosef Durr, Lead Senior Program Manager, Microsoft mentions on Windows Blog,

The use of package managers in modern development has also exploded in recent years. For example, node package manager (npm) served ~400 million installs in the week of July 1st, 2015, but served more than 1.2 billion installs just one year later – a 3x increase in just one year! In late June 2016, npm served more than 1.7 billion node packages in just seven days!

Although Symlinks have distinct advantages, it was primarily utilized by UNIX-compatible operating systems like Linux, FreeBSD, OSX, etc., where symlinks can be created without restrictions. For Windows users, although Symlinks was made available starting from Windows Vista, it was difficult and tedious to create. Because of Windows Vista’s security requirements, users needed local admin rights and, importantly, had to run mlink in a command-line console elevated as administrator to create/modify Symlinks. This latter restriction resulted in Symlinks being infrequently used by most Windows developers and caused many modern cross-platform development tools to work less efficiently and reliably on Windows. However, now on Windows 10 or Windows 11, once a user with admin rights enables Developer Mode, anybody on the PC can run the mklink command without elevating a command-line console.

Symlinks can be created either using the mklink command or the CreateSymbolicLink API. You can make Symlinks or Symbolic Links in Windows, using the command-line utility: mklink. The syntax is as follows: Where –

/D: creates a symbolic directory link or soft link/H: creates a hard link to a file instead of a symbolic link/J: creates a Directory Junction link

Target: Specifies the path that the new link refers to. Now for example, if you want d:\Data to be made available from the folder D:\Maindata use: Now, if you now look in D:\Maindata, you will see whatever files that were there in the other directory. It has always been there in Linux, but this feature has now been made available in Vista too.

While using mklink command, use the below syntax: Note: mklink can create several types of links. Below are the types-

/D      Creates a directory symbolic link. The default is a file symbolic link./H      Creates a hard link instead of a symbolic link./J      Creates a Directory Junction.

For instance, I created a directory junction of my Music folder to my desktop. Refer the below screenshot-

So when I click on the Symlink, it looks that my music files are stored in C:\Users<username>\Desktop\Music although it is originally present in C:\Users<username>\Music.

Remember, if your path has any spaces in it, then you need to place quotes around it.

To enable the new behavior when using the CreateSymbolicLink API, there is an additional dwFlags option you will need to set the value as: SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE 0x2 So by choosing the above value, you have specified the flag to allow the creation of symbolic links when the process is not elevated. To read more on how to create Symlink using CreateSymbolicLink API, visit windows.com. Read: Create Hardlinks, Symbolic Links, Junctions, Volume Mountpoints.

Conclusion

It can be said that Symlinks are more useful than mere shortcuts however they are a bit difficult to create. An average PC user may still find it a little scary to create. What’s more, even today, many users struggle to understand the concept of shortcuts well and hence may struggle to differentiate Symlinks and understand its use. Having said that, it is almost a guarantee that you will find it easy to change whatever settings you can so that a program is pointing to the right directory, and you don’t really create a Symlink, but knowing how to set up and use a good Symlink can be really handy.