Search notes:

cmd.exe - mklink

Create symbolic links

By default, mklink creates symbolic links in NTFS.
administrator privileges are required to create a symbolic link unless Windows is put into developer mode.
The following example uses echo and the redirection operator (>) to create a file (target.txt) whose content is Some Text. Then, a symbolic link is created with mklink. Using type on sym.link shows the same content as is in target.txt:
@echo off

echo Some Text> target.txt
mklink sym.link target.txt
type            target.txt
Github repository about-cmd.exe, path: /commands/mklink/create-symbolic-link.bat

Create hard links

A hard link can be created with the /h flag:
mklink /h path\to\new-link path\to\existing-file
Hard links can only be created for files, not for directories.
No administrator privileges are required to create a hard link.

Create a junction

A junction is created with the /j flag:
mklink /j new\path old\path
No administrator privileges are required to create a junction.
In PowerShell, a junction can be created with new-item and -itemType junction:
new-item -itemType junction -path lnk -target existing-dir

See also

Reparse points
cmd.exe: Built-in commands

Index