How To Use The Mklink Command In Windows (2027)
Mklink creates a link, which is a second path that points to an existing file or folder, from Command Prompt.
The basic form is mklink , with the new link name first and the existing item second.
This guide follows Microsoft’s mklink reference and its file-linking pages, so each link type below is documented.
Table of Contents
- Mklink quick answers
- Open Command Prompt as administrator
- The mklink syntax
- Mklink switches at a glance
- Symbolic link, hard link or junction
- Create a file symbolic link
- Create a folder symbolic link
- Create a hard link
- Create a directory junction
- Relative and absolute targets
- What a hard link cannot do
- How changes show up through a hard link
- Create symbolic links without administrator rights
- Which link type to use
- Remove a link without deleting the target
- The PowerShell alternative
- Limits to know about
- Related guides
- Official sources
- More Windows guides
Mklink quick answers
| I want to | Type this |
|---|---|
| Link to a file (symbolic link) | mklink |
| Link to a folder (symbolic link) | mklink /d |
| Make a hard link to a file | mklink /h |
| Make a directory junction | mklink /j |
| Remove a folder link | rd |
| Remove a file link | del |
Replace the placeholders with real paths, and keep the link name first.
Open Command Prompt as administrator
- Press the Windows key and type cmd.
- Right-click Command Prompt and choose Run as administrator.
- Type your mklink command and press Enter.
Microsoft’s PowerShell documentation says creating a symbolic link on Windows requires elevation as administrator, unless Developer Mode is on in Windows 10 build 14972 or newer.
The steps for an elevated window are in how to open Terminal as administrator.
The mklink syntax
Microsoft gives the syntax as mklink [[/d] | [/h] | [/j]] .
The link is the name of the new link, and the target is the path, relative or absolute, that it refers to.
Without a type switch, mklink creates a file symbolic link.
Mklink switches at a glance
| Switch | What it creates |
|---|---|
| None | A file symbolic link, which is the default. |
/d | A directory symbolic link. |
/h | A hard link instead of a symbolic link. |
/j | A directory junction. |
Symbolic link, hard link or junction
| Link type | Points to | Limits Microsoft documents |
|---|---|---|
| Symbolic link | A file or a directory | The target can be relative or absolute, and a link can point to a target that does not exist. |
| Hard link | A file only | Cannot reference directories, or files on a different volume. |
| Junction | A directory only | Can link directories on different local volumes, but not mapped network volumes. |
Microsoft describes a hard link as more than one path referencing a single file on the same volume.
It describes a junction as a link to a separate directory, and notes that junctions are implemented through reparse points.
Create a file symbolic link
- Open an elevated Command Prompt.
- Run
mklink C:\Links\notes.txt C:\Docs\notes.txtwith your own paths. - Open the new link to confirm it shows the contents of the target.
The paths in the example are placeholders, and the target here is the existing file.
Create a folder symbolic link
Microsoft’s own example is mklink /d \MyFolder \Users\User1\Documents.
That makes a link named MyFolder that opens the Documents folder, because the /d switch marks it as a directory link.
Create a hard link
Microsoft’s example is mklink /h \MyFile.file \User1\Documents\example.file.
Any change made to a hard-linked file is instantly visible through every link that references it.
Microsoft also says you can delete hard links in any order, whatever order they were created in.
Create a directory junction
Use mklink /j when you want a folder link between local volumes.
Microsoft says a junction can link directories located on different local volumes on the same computer.
A junction cannot point at a file or at a mapped network volume.
Relative and absolute targets
Microsoft says absolute links specify each portion of the path, while relative links are determined relative to where the link sits.
| Target form | Resolves to |
|---|---|
..\folder | Relative to the parent directory. |
folder | Relative to the current directory. |
\Windows\System32 | Relative to the root of the current drive. |
| A path with a device name | Treated as an absolute link. |
What a hard link cannot do
| Example | Allowed? |
|---|---|
| A file linked to another file on the same volume | Yes. |
| A directory linked to another directory | No, hard links cannot reference directories. |
| A file on C: linked to a file on D: | No, they cannot reference files on different volumes. |
| A file linked to a file on a mapped network drive | No. |
If a hard link fails for one of those reasons, use a symbolic link or a junction instead.
How changes show up through a hard link
Microsoft says the attributes of the file are reflected in every hard link to it.
However, the directory entry size and attribute information are visibly updated only at the link through which the change was made.
Microsoft’s example is clearing the read-only flag on one link, which leaves the other links still showing read-only.
Create symbolic links without administrator rights
Microsoft says Windows 10 build 14972 or newer with Developer Mode enabled no longer requires elevation to create symbolic links.
Its API documentation adds that Developer Mode must first be enabled on the machine for the unprivileged option to work.
Without Developer Mode, run the command from an elevated window.
Which link type to use
- Use a symbolic link when the target can be a file or a folder, or when you want a relative path.
- Use a hard link when two paths on the same volume should reference one file.
- Use a junction when you need a folder link across local volumes.
Remove a link without deleting the target
Microsoft’s example removes a directory link with rd \MyFolder and a file link with del \MyFile.file.
Use rd on the folder link itself, never on the target path.
Microsoft’s API documentation says file links are deleted with file delete calls and directory links with directory removal calls.
The PowerShell alternative
PowerShell’s New-Item cmdlet takes an -ItemType of SymbolicLink, Junction or HardLink.
Microsoft’s example is New-Item -ItemType SymbolicLink -Path .\link -Target .\Notice.txt.
Before PowerShell 6.2, the target had to be a fully qualified path.
Limits to know about
- Microsoft says a path can contain a maximum of 63 reparse points, and symbolic links are reparse points.
- A symbolic link can point to a target that does not exist, and Windows does not check when you create it.
- Opening a link whose target is missing returns a file not found error.
- Microsoft notes that the Cluster Shared Volume file system does not support soft links or other reparse points.
Related guides
To copy folders and files with a command, see the Robocopy guide, and for another storage task see how to mount an ISO file.
For another command-line task, see the reg add guide.
Official sources
The switches and examples come from Microsoft’s mklink reference.
The link type limits come from Microsoft’s hard links and junctions page, and the target rules come from the CreateSymbolicLinkW reference.
The PowerShell details come from Microsoft’s New-Item reference.
More Windows guides
- How To Use The Takeown Command In Windows (2027)
- How To Use The Icacls Command In Windows (2027)
- How To Use The Findstr Command In Windows (2027)
- How To Use The Runas Command In Windows (2027)
- How To Use The Reg Add Command In Windows (2027)
- How To Use The Schtasks Command In Windows (2026)
See all: Windows 11 Guides