Create Symbolic Links (Symlinks) In Windows

All moderns operating systems as well as Windows XP, Windows 7, Windows 8, Windows 10, and Windows Server versions provide the Symbolic links (symlinks) in order to point and access the specific directory, folder, path, directory, etc. Symlinks are very useful where without copying the original data the data or data path can be accessed another location.

What Is Symbolic Link?

Symbolic links can be called as shortcuts to a file or folder. When a symbolic link is created it will look like the source of the symbolic link which simply points to the source file or folder. Symbolic links can be used for both files or folders also for a path.

Symbolic links can be used for different cases like providing a file in another directory or path which is required like a library or DLL.

Popular cloud file storage and backup systems can be also used for Dropbox, Google Drive, OneDrive where different folders symbolic links can be put inside the shared and synced folder and all of the contents of this symbolic link will be shared too.

There is two type of symbolic links.

Soft Symbolic Link

The Soft Symbolic Link is similar to the file or folder shortcut. When double-clicked or provided to a command the original file or folder is opened. When the soft symbolic link is deleted the source does not change and only the symbolic link is deleted.

Hard Symbolic Link

The Hard Symbolic Link is a bit different where it provides direct access to the source file or folder. If the hard symbolic link is deleted the source is deleted too which is different from a soft symbolic link.

READ  Windows tracert Command For Trace Route

In order to create a symbolic link which can be a soft symbolic link or hard symbolic link, the mlink command is used. The usage of the mlink command in the creation of a soft symbolic link or hard symbolic link is explained below.

Create Symbolic Link with File Explorer GUI

Even shortcuts can be used as a link to different files and folders they are not a symbolic link as they are files with “*.lnk” extension. Even symbolic links can be created via command line mlink command in order to create a symbolic link the Link Shell Extension should be used in GUI or Windows Desktop. The Link Shell Extension can be downloaded and installed from the following link.

http://schinagl.priv.at/nt/hardlinkshellext/linkshellextension.html

After the installation of the Link Shell Extension is complete the File Exploerer is restarted which will enable it. First the source file of folder should be specified with the “Pick Link Source”. Right click to the source file of folder you want to create a symlink.

Select Symbolic Link Source

The we will navigate to the path we want to create the soft or hard link. In this case we will create a soft link. First right click and select the “Drop As…” like below. From there click to the “Symbolic Link“.

Create New Symbolic Link

The symbolic link creation may require administrative privilege by using the Link Shell Extension which will ask the following question. Just click on the “Yes” which will create the new symbolic link.

After we have created the symbolic link we will see that it looks like a shortcut that will use the shortcut symbol like below. We can get more information about it by investigating the Properties which can be opened by right-clicking on it.

Open Symbolic Link Properties

In properties window navigate to the “Link Properties” tab which will provide the link type which can be a Symbolic Link or Hard Link. Also the target or source of the link is provided. By clicking to the Explore Target the target can be opened in File Explorer.

Symbolic Link Properties

Create Symbolic Link with mlink Command

Windows operating systems provides the mlink command in order to create symbolic links which can be a soft link or hard link. The mlink command can be used for both MS-DOS and PowerShell command line interfaces. This command requires administrator privielges where the command line interfaces should be opened as administrator with the “Run as administrator” like below.

The syntax of the mlink command is like below.

mlink LINK TARGET
  • LINK is the newly created link name which can be created in the current working directory or specified absolute path.
  • TARGET is the source file or folder which is linked to.
READ  How To Create New Directory In PowerShell?

Create Soft Symbolic Link To A File

The default action for the mlink command is creating a soft symbolic link into a file. If we do not provide any option by just providing the link and target the soft symbolic link will be created for a file. In the following example we will create a soft symbolic link named “data” for the “D:\data” file.

mlink data "D:\data"

Alternatively the link can be specified as absolute path.

mlink "C:\Users\ismail\data" "D:\data"

Create Soft Symbolic Link To A Directory

In order to create a soft symbolic link for a directory, the /D parameter should be used with the link and target parameters.

mlink /D backup "D:\backup"

Alternatively the link can be specified as absolute path.

mlink /D "C:\Users\ismail\backup\" "D:\backup\"

Create Hard Symbolic Link To A File

By using the mlink command hard link into a file can be created from the command-line interface. In order to create a hard link into a file the /H parameter provided with the link and the target.

mlink /H data "D:\data"

Alternatively the link can be specified as absolute path.

mlink /H "C:\Users\ismail\data" "D:\data"

Create Hard Symbolic Link To A Directory/Folder

A hard link into a directory or folder can be created by using the /J parameter with the mlink command. A hard link into a directory also called a junction. In the following example, we will create a hard symbolic link into the folder named “backup”.

mlink /H backup "D:\backup"

Alternatively the link can be specified as absolute path.

mlink /H "C:\Users\ismail\backup\" "D:\backup\"

Delete Symbolic Links with File Explorer GUI

It is very easy to delete a symbolic link from the File Explorer GUI. Just navigate to the symbolic link directory and right-click to the link and click the “Delete” from the menu like below. This will delete the link not the source or target file or folder.

Delete Symbolic Links with File Explorer GUI

Leave a Comment