Create symbolic links
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
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.
new-item -itemType junction -path lnk -target existing-dir