The mklink command is used to create a symbolic link through the Windows command line.
Availability
Mklink is an internal command that’s available in the following Microsoft operating systems.
Availability
Mklink syntax
Mklink examples
Related information
Windows Vista
Windows 7
Windows 8
Windows 10
Windows 11
Mklink syntax
MKLINK [[/D] | [/H] | [/J]] Link Target
Mklink examples
mklink /d \Docs \Users\Hope\Documents
The example command above would create a symbolic link called Docs to the \Users\Hope\Documents directory, even if the directory does not exist. If the link is successfully created, you will see a message similar to the one shown below.
The mklink command requires you to be in an elevated command prompt.
Symbolic link created for \Docs «===» \Users\Hope\Documents
Once the symbolic link is created, using the dir command you can see any symbolic link in the directory listing of where it was created. Below is an example of what the previous symbolic link directory,
To get into the symbolic link directory, you would treat it like any other directory and use the cd command. To get into the Docs directory, you would type “cd docs” at the prompt as if it was a directory.
How do I create a junction point?
To create a junction point to a local directory, perform the following command. As seen, we are using the /j switch instead of the /d switch.
A junction point can only link to a local directory.
mklink /j example backup
If created successfully, you will see a message similar to the example shown below.
Junction created for example «===» backup
Once the junction is created, using the dir command you can see any junction in the directory listing of where the junction was created. Below is an example of what the above junction directory
How do I create a symbolic link or junction to a directory with a space?
If the file or directory you want to link or point to contains a space in its name, it must be surrounded with quotes. In the example below, we are creating a symbolic link to the “c:\program files” directory from the current directory.
mklink /d files “c:\program files”
How do I delete a symbolic link?
To delete a symbolic link, treat it like any other directory or file. If you created a symbolic link using the command shown above, move to the root directory since it is “\Docs” and use the rmdir command. If you created a symbolic link (
How do I delete a junction point?
A junction point is only going to be a directory, so you should only need to use the rmdir command to remove it.
Will deleting a symbolic link or junction point delete the linked files or directory?
No. When you delete a symbolic link or a junction point, it’s only removing the link or pointer and not the file or directory to which it’s pointing. However, if you create a directory symbolic link or junction point and open that link or pointer and delete files in the directory, those files are deleted.
Related information
- See our symbolic link page for further information on this term.
- See our junction page for further information on this term and information about the differences between a symbolic link and junction point.