Creating Symbolic Links (Symlinks) in Windows | Windows OS Hub (2024)

A symbolic link (symlink) is a special file on a file system that doesn’t contain any data but is actually a shortcut pointing to another object (file or folder). When accessing a symlink, the operating system thinks that it is an original file (folder) and works with it completely transparently.

Symbolic links are quite often used in Windows for system files and directories. You may use them when you need to move large files to another disk and Windows must consider that they are still located in the original directory (for example, when you want to save space on an SSD by moving some directories to a slower and larger HDD without disrupting programs). You can use symlinks on your SMB file server when directories located in different LUNs must be available in a single entry point.

The three types of file links available in Windows for NTFS volumes: hard links, soft links (symlinks), and Junction Points.

  • Hard Links can only point to a local file, but not to a folder. A hard link is a file link to another file on the same volume without duplicating the file. It has the same size and properties as the source file (but it does not take up real space on the drive);
  • Junction Points (Directory Hard Link) can only point to a directory (on the same or another volume);
  • Symbolic Links (soft link, symlink) can point to a local file, folder, or network share on a remote computer (by the UNC path). Relative paths are supported.

In most cases, you can use a symlink for most tasks when you need to create a reference to an object.

How to Create a Symbolic Link in Windows?

To create symbolic or hard links in Windows, you can use the built-in mklink tool or PowerShell.

Creating Symbolic Links (Symlinks) in Windows | Windows OS Hub (1)

mklink has a simple syntax. To create a symbolic link to a file, specify the link name and the target object you want it to point to. You can set the link type: /D — a symbolic (soft) link to a directory, /H — a hard link, /J – a Junction point.

In order to use mklink for creating symbolic links, run the command prompt as administrator. Otherwise, when you run the command, the following error will appear: You do not have sufficient privilege to perform this operation.

If you want to allow non-admin users to create symbolic links, add the user group to Create Symbolic Links GPO option (Computer Configuration -> Window Settings -> Security Settings -> User Rights Assignment in the GPO editor). By default, only the local Administrators group is added to the policy. Update local Group Policy after changing the setting: gpupdate /force

Creating Symbolic Links (Symlinks) in Windows | Windows OS Hub (2)

Create a symbolic link to the notepad.exe file in C:\PS:

mklink C:\PS\note.exe c:\Windows\System32\notepad.exe

You will see the following message:

symbolic link created for C:\PS\note.exe <<===>> c:\Windows\System32\notepad.exe

Now you can use the note.exe symlink to run notepad.exe.

Create a symlink to another folder on the same drive:

mklink /D "C:\PS\Downloads" "C:\Users\user\Downloads"

Creating Symbolic Links (Symlinks) in Windows | Windows OS Hub (3)

Now, when you open the C:\PS\Downloads folder you will see the contents of the directory it refers to.

Creating Symbolic Links (Symlinks) in Windows | Windows OS Hub (4)

Display the contents of C:\PS:

dir c:\ps

As you can see, the attributes of some files show that it is a symlink (simlinkd). The object they refer to is also displayed. In File Explorer, symlinks are displayed as shortcut icons, and the target object they point to is shown in their properties.
Creating Symbolic Links (Symlinks) in Windows | Windows OS Hub (5)

You can also create a symbolic link in Windows using PowerShell (in this example I use relative paths to create symlink):

New-Item -ItemType SymbolicLink -Path ".\test\tmpfiles" -Target "..\tmp\files"

Creating Symbolic Links (Symlinks) in Windows | Windows OS Hub (6)

You can create a symbolic link to a shared network folder on a remote computer or server. Specify the network share address in the UNC format.

mklink /D c:\ps\share \\hq-fs01\Share

For example, let’s connect the administrative share C$ on a remote computer using its IP address:

mklink /D c:\remotePC\server1 \\192.168.13.10\C$

If you see the following error when accessing a share using a symlink:

The symbolic link cannot be followed because its type is disabled.

Check the allowed ways of using symbolic links on your computer:

fsutil behavior query SymlinkEvaluation

Local to local symbolic links are enabled.Local to remote symbolic links are enabled.Remote to local symbolic links are disabled.Remote to remote symbolic links are disabled.

Creating Symbolic Links (Symlinks) in Windows | Windows OS Hub (7)

To enable symbolic links to remote resources, run the following commands:

fsutil behavior set SymlinkEvaluation R2R:1
fsutil behavior set SymlinkEvaluation R2L:1

You can work with symbolic links in the same way as with ordinary file system objects: move, rename, or delete them. Windows will automatically change the settings of the symlinks so that they point to the correct targets.

To remove symlinks, the usual commands are used (like you do for files):

Del c:\ps\note.exe
RD c:\ps\downloads

How to Find All Symbolic Links on a Windows Drive?

There are no built-in tools in Windows to view and manage all symlinks on a disk.

You can list all symbolic links on a disk using this command:

dir /AL /S C:\ | find "SYMLINK"

  • /A – to display files with L attribute (symlinks)
  • /S –run the command recursively for all subfolders
  • C:\ — specify a drive name or path to a folder to search for symlinks

Creating Symbolic Links (Symlinks) in Windows | Windows OS Hub (8)

You can also get a list of all symbolic links on a disk using PowerShell. Just scan all folders and find NTFS objects with the ReparsePoint attribute:

Get-ChildItem -Path C:\ -Force -Recurse -ErrorAction 'silentlycontinue' | Where { $_.Attributes -match "ReparsePoint"}

Creating Symbolic Links (Symlinks) in Windows | Windows OS Hub (2024)
Top Articles
Latest Posts
Article information

Author: Greg Kuvalis

Last Updated:

Views: 5853

Rating: 4.4 / 5 (75 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Greg Kuvalis

Birthday: 1996-12-20

Address: 53157 Trantow Inlet, Townemouth, FL 92564-0267

Phone: +68218650356656

Job: IT Representative

Hobby: Knitting, Amateur radio, Skiing, Running, Mountain biking, Slacklining, Electronics

Introduction: My name is Greg Kuvalis, I am a witty, spotless, beautiful, charming, delightful, thankful, beautiful person who loves writing and wants to share my knowledge and understanding with you.