Symbolic Links
- Works with both files and directories
- Can be mapped to files and directories on different drives, network volumes, etc.
- They can work with relative paths as well
:: Symbolic Link
mklink /D <Link> <Target>
:: View all Symbolic Links and Junctions in a Directory
DIR /AL /S <Location>
/D
Directory Link
<Link>
: The target link (should not already exist)
<Target>
: The actual file/folder to link
# PowerShell native approach
New-Item -ItemType SymbolicLink -Path C:\LinkDir -Value F:\RealDir
# Calling CMD Command from PowerShell
cmd /c mklink c:\path\to\symlink c:\target\file
rmdir
and del
commands can be used to remove Symbolic Links. This command should to run on the target location (the Symbolic Link)
View a list of symbolic links on system? - Super User
Soft Links (Junction)
- Can be only made for Directories
- The target directory needs to be on the same computer (different volume is allowed)
- The paths needs to be absolute paths
:: Junctions
mklink /J
Hard Links
- Can be only made for files
- Can be only used to point on files on the same volume (Drive with same letter)
- If the hard linked file changes location the hard link automatically updates
- Hard links look exactly the same as the file (Need to be careful to not delete the wrong file)
:: Hard Links
mklink /H