How to Create Soft and Hard Symbolic Links in Windows
There are three types of file links supported in the NTFS file system: hard links, junctions, and symbolic links. Otherwise known as Reparse Points.
Hard Links can only be created for files. Any changes to that file are instantly visible to applications that access it through the hard links that reference it. Hard links do not support UNC paths (network paths that begin with \\). Hard links to a file will not have a shortcut arrow icon on them.
Symbolic Links are soft links that are basically advanced shortcuts. You can create a symbolic link to a local or remote file, folder, or shares path, and that link will appear to be the same as the target source. Symbolic links do support UNC paths (network paths that begin with \\). When you open a symbolic link, you will be redirected to the target source. Symbolic links will have a shortcut arrow icon on them.
Junctions (Directory Junction) are soft links that can only be created to a local folder (directory) path. Junction points make it appear as though folder (directory) actually exists at the location of the junction point, and your app won’t know any better. Junction points do not support UNC paths (network paths that begin with \\). Junction points will have a shortcut arrow icon on them.
Deleting anything in the link/junction or target (source) folder will delete it in both folders.
Deleting the hard link, symbolic link, or junction point itself will not delete anything in the target (source) folder.
See also:
- Symbolic Links - Windows applications | Microsoft Docs
- Hard Links and Junctions | Microsoft Docs
- NTFS symbolic link - Wikipedia
- Hard link - Wikipedia
- mklink | Microsoft Docs
- New-Item | Microsoft Docs
A symbolic link can be helpful if say you wanted to sync a folder for a program. For example, if you have a program that must have its files stored at C:\Program Files and you want them stored at D:\My Location instead. You could move the original directory from C:\Program Files to D:\My Location, and create a symbolic link (soft or hard) at C:\Program Files (link) pointing to D:\My Location (target).
This tutorial will show you how to create soft and hard symbolic links (symlinks) pointing to a file or folder in Windows 7, Windows 8, Windows 10, and Windows 11.
If you have Developer Mode turned on in Windows 10, you will need to use the mklink command in a normal command prompt instead of the usually required elevated command prompt.
Contents
- Option One: Create Symbolic Link Pointing to File in Command Prompt
- Option Two: Create Symbolic Link Pointing to Directory in Command Prompt
- Option Three: Create Hard Link Pointing to File in Command Prompt
- Option Four: Create Junction Point to Directory in Command Prompt
- Option Five: Create Symbolic Link Pointing to File in PowerShell
- Option Six: Create Symbolic Link Pointing to Directory in PowerShell
- Option Seven: Create Hard Link Pointing to File in PowerShell
- Option Eight: Create Junction Point Pointing to Directory in PowerShell
- Option Nine: Delete Hard Link, Symbolic Link, or Junction Point
1 Open an elevated command prompt.
2 Type the command below into the elevated command prompt, and press Enter. (see screenshot below)
mklink "Link" "Source Target"
Substitute Link in the command above with the full path with file name and extension you want created as a soft symbolic link at.
Substitute Source Target in the command above with the full path of the file with extension that is the target (source) you want the soft symbolic link pointing to. This is the actual location where everything will be saved at.
For example:mklink "C:\Users\Brink\Desktop\My Documents Link.txt" "C:\Users\Brink\Documents\My Document.txt"
3 When finished, you can close the elevated command prompt if you like.
1 Open an elevated command prompt.
2 Type the command below into the elevated command prompt, and press Enter. (see screenshot below)
mklink /d "Link" "Source Target"
Substitute Link in the command above with the full path of a folder (directory) you want created as a soft symbolic link at.
Substitute Source Target in the command above with the full path of the folder (directory) that is the target (source) you want the soft symbolic link pointing to. This is the actual location where everything will be saved at.
For example:mklink /d "C:\Program Files\Mozilla Firefox" "D:\Mozilla Firefox"
3 When finished, you can close the elevated command prompt if you like.
1 Open an elevated command prompt.
2 Type the command below into the elevated command prompt, and press Enter. (see screenshot below)
mklink /h "Link" "Source Target"
Substitute Link in the command above with the full path with file name and extension you want created as a hard link at.
Substitute Source Target in the command above with the full path of the file with extension that is the target (source) you want the hard link pointing to. This is the actual location where everything will be saved at.
For example:mklink /h "C:\Users\Brink\Desktop\My Documents Link.txt" "C:\Users\Brink\Documents\My Document.txt"
3 When finished, you can close the elevated command prompt if you like.
1 Open an elevated command prompt.
2 Type the command below into the elevated command prompt, and press Enter. (see screenshot below)
mklink /j "Link" "Source Target"
Substitute Link in the command above with the full path of a folder (directory) you want created as a soft link at.
Substitute Source Target in the command above with the full path of the folder (directory) that is the target (source) you want the soft link pointing to. This is the actual location where everything will be saved at.
For example:mklink /j "C:\Program Files\Mozilla Firefox" "D:\Mozilla Firefox"
3 When finished, you can close the elevated command prompt if you like.
1 Open an elevated PowerShell.
2 Type the command below into the elevated PowerShell, and press Enter. (see screenshot below)
New-Item -ItemType SymbolicLink -Path "Link" -Target "Source Target"
Substitute Link in the command above with the full path with file name and extension you want created as a soft symbolic link at.
Substitute Source Target in the command above with the full path of the file with extension that is the target (source) you want the soft symbolic link pointing to. This is the actual location where everything will be saved at.
For example:New-Item -ItemType SymbolicLink -Path "C:\Users\Brink\Desktop\My Documents Link.txt" -Target "C:\Users\Brink\Documents\My Document.txt"
3 When finished, you can close the elevated PowerShell if you like.
1 Open an elevated PowerShell.
2 Type the command below into the elevated PowerShell, and press Enter. (see screenshot below)
New-Item -ItemType SymbolicLink -Path "Link" -Target "Source Target"
Substitute Link in the command above with the full path of a folder (directory) you want created as a soft symbolic link at.
Substitute Source Target in the command above with the full path of the folder (directory) that is the target (source) you want the soft symbolic link pointing to. This is the actual location where everything will be saved at.
For example:New-Item -ItemType SymbolicLink -Path "C:\Program Files\Mozilla Firefox" -Target "D:\Mozilla Firefox"
3 When finished, you can close the elevated PowerShell if you like.
1 Open an elevated PowerShell.
2 Type the command below into the elevated PowerShell, and press Enter. (see screenshot below)
New-Item -ItemType HardLink -Path "Link" -Target "Source Target"
Substitute Link in the command above with the full path with file name and extension you want created as a hard link at.
Substitute Source Target in the command above with the full path of the file with extension that is the target (source) you want the hard link pointing to. This is the actual location where everything will be saved at.
For example:New-Item -ItemType HardLink -Path "C:\Users\Brink\Desktop\My Documents Link.txt" -Target "C:\Users\Brink\Documents\My Document.txt"
3 When finished, you can close the elevated PowerShell if you like.
1 Open an elevated PowerShell.
2 Type the command below into the elevated PowerShell, and press Enter. (see screenshot below)
New-Item -ItemType Junction -Path "Link" -Target "Source Target"
Substitute Link in the command above with the full path of a folder (directory) you want created as a hard link at.
Substitute Source Target in the command above with the full path of the folder (directory) that is the target (source) you want the hard link pointing to. This is the actual location where everything will be saved at.
For example:New-Item -ItemType Junction -Path "C:\Program Files\Mozilla Firefox" -Target "D:\Mozilla Firefox"
3 When finished, you can close the elevated PowerShell if you like.
1 Open File Explorer (Windows 8/10) or Windows Explorer (Windows 7).
2 Navigate to the location of the link or junction point, and delete it. This will not delete the target (source) the link/junction points to.
Do not delete the target (source) the link/junction points to. You only want to delete the link/junction itself.
That's it,
Shawn Brink
Related Tutorials
- Find All Symbolic Links and Junction Points in Windows
- How to Create Shortcut to App, File, Folder, Drive, or Website in Windows 10
- Sync Any Folder to OneDrive in Windows 11 and Windows 10
- How to Mount a Drive to a Folder in Windows 10
- How to Mount Folder as Virtual Drive in Windows 7, Windows 8, and Windows 10