Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Windows 10 / Creating Symbolic Links (Symlinks) in Windows

November 10, 2022 Windows 10Windows Server 2019

Creating Symbolic Links (Symlinks) in Windows

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.

mklink command on Windows

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

GPO: Allow to Create Symbolic Links

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"

Windows cmd: symbolic link created for ...

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

create symlink on Windows folder

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.

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"

Create Symbolic Link in Windows with PowerShell

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.

fsutil behavior query SymlinkEvaluation

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

How to List All Symlinks in the Windows Directory or Drive

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"}

1 comment
1
Facebook Twitter Google + Pinterest
previous post
Configuring Windows Firewall Rules Using Group Policy
next post
Install and Configure PostgreSQL on Windows

Related Reading

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

How to Use Ansible to Manage Windows Machines

September 25, 2023

Installing Language Pack in Windows 10/11 with PowerShell

September 15, 2023

How to View and Change BIOS (UEFI) Settings...

September 13, 2023

1 comment

afadfadf July 26, 2023 - 4:56 pm

why is this formatted so strange. hard to read.

Reply

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • How to Allow Multiple RDP Sessions on Windows 10 and 11
  • How to Repair EFI/GPT Bootloader on Windows 10 or 11
  • How to Restore Deleted EFI System Partition in Windows
  • Network Computers are not Showing Up in Windows 10/11
  • How to Run Program without Admin Privileges and Bypass UAC Prompt
  • Fix: BSOD Error 0x0000007B (INACCESSABLE_BOOT_DEVICE) on Windows
  • Fixing ‘The Network Path Was Not Found’ 0x80070035 Error Code on Windows
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top