mklink - Create Links

Maintained on
Table of Contents

The mklink command creates links on the file system.

They are similar to Explorer shortcuts, but links created with mklink are handled at the file-system level, so command lines and applications can use them almost like ordinary files and folders.

mklink [[/d] | [/h] | [/j]] <link> <target>
ElementDescription
<link>Path of the new link to create
<target>Path of the file or folder the link points to
/dCreates a symbolic link to a directory
/hCreates a hard link to a file
/jCreates a directory junction

Choose the type of link according to your purpose.

TypeHow to createMain use
File symbolic linkNo optionRefer to a file located elsewhere
Directory symbolic link/dRefer to a whole folder from another location
Hard link/hGive one file multiple names on the same volume
Directory junction/jRefer to a local folder from another location without administrator rights
Symbolic links vs. shortcuts

A shortcut is a .lnk file, whereas a symbolic link is a file-system link. When used from commands or applications, a mklink link is often more natural to work with than a shortcut.

The main differences between symbolic links and junctions are as follows.

ItemSymbolic linkDirectory junction (/j)
TargetFiles and foldersFolders only
Relative target pathAllowedStored as an absolute path
Network pathsAllowedNot allowed (local only)
Administrator rightsUsually requiredNot required

Hard links can also be created without administrator rights.

If you cannot use administrator rights but want to expose a folder at another location, a junction is the easy choice.

Basic usage

mklink C:\work\latest.log C:\logs\2026-04-20.log
- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>mklink C:\work\latest.log C:\logs\2026-04-20.log
symbolic link created for C:\work\latest.log <<===>> C:\logs\2026-04-20.log
C:\users\user>
mklink /d C:\work\assets D:\shared\assets
mklink /h C:\work\report-latest.txt C:\archive\report.txt
Hard link restrictions

Hard links can only be created for files and must be on the same volume. They cannot be used for folders.

Create a directory junction

mklink /j C:\work\current D:\projects\current

When you run the dir command, links are shown as <SYMLINK> (file symbolic link), <SYMLINKD> (folder symbolic link) or <JUNCTION> (junction). Hard links are not distinguished from ordinary files.

dir C:\work

Use dir /al to list only symbolic links and junctions. For hard links, fsutil hardlink list <file> shows every name that points to the same data.

Which one should I use?

  • To refer to a folder across drives, first consider a symbolic link or a junction.
  • To give one file multiple names, a hard link is suitable.
  • To have batch files or tools treat it “like a real path”, mklink is better than a shortcut.

Notes

About privileges

In many environments, creating a symbolic link requires administrator rights. However, on Windows 10 / 11 with Developer Mode enabled, you may be able to create them without administrator rights.

  • Symbolic links can be created with either relative or absolute paths.
  • Creation fails if a file or folder already exists at the link path (<link>).
  • A symbolic link can be created even when the target does not exist, but opening that link results in an error.
  • A hard link is another name for the same data as the original file. Deleting one name does not stop you from reading the content through the other.
  • When you create a symbolic link with a relative path, the target is interpreted relative to the location of the link.
  • Deleting a link with the proper command does not delete the original file or folder it points to.

When you see “You do not have sufficient privilege”

Creating a symbolic link without administrator rights fails with this error.

- □ ×
Command Prompt Icon
Command Prompt
Microsoft Windows [Version xx.x.xxxxx.xxx]
(c) 2026 Ribbit App Development All rights reserved.
 
C:\users\user>mklink C:\work\latest.log C:\logs\2026-04-20.log
You do not have sufficient privilege to perform this operation.
C:\users\user>

Run the Command Prompt as administrator, or turn on Developer Mode in Windows settings. For folders, you can also use /j (junction), which needs no administrator rights.

mklink is an internal Command Prompt command, so it cannot be run directly in PowerShell. Run it through cmd /c, or use New-Item (the two lines below are alternatives that create the same link).

cmd /c mklink /d C:\work\assets D:\shared\assets
New-Item -ItemType SymbolicLink -Path C:\work\assets -Target D:\shared\assets

To delete only the link, use the deletion command that matches the type of link.

del C:\work\latest.log
rmdir C:\work\assets
Do not use del on folder links

Running del on a folder symbolic link or junction deletes the files inside the target folder. To remove a folder link, always use rmdir (without /s).

Be careful what you delete

What you delete here is only the link. To delete the actual target, specify the original path.

Quiz

Practice Problem

Practice Problem

#Command Prompt #Batch Files #mklink #Command Line #Commands