mklink - Create Links

Maintained on

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

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

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.
  • 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.

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

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