Skip to content

MKLINK command in Windows

The Windows mklink command allows users to create symbolic links and hard links between files and folders. This can help improve file organization, save disk space, and make accessing files easier. By using the mklink command, users can create a symbolic link that points to a target file or folder, allowing them to access the target through the symbolic link. Hard links, on the other hand, create additional references to the target file or folder, saving disk space by eliminating the need for duplicate files. Using the mklink command can be a powerful tool for managing files and folders efficiently in Windows.

Terminal window
mklink /D Link Target
mklink /H Link Target
mklink /J Link Target
OptionDescription
/DCreates a directory symbolic link.
/HCreates a hard link.
/JCreates a directory junction.
ParameterDescription
LinkSpecifies the name of the symbolic link to be created.
TargetSpecifies the path (relative or absolute) that the new link will refer to.
Terminal window
mklink /d "C:\myFolderLink" "D:\myFolder"

Creates a symbolic link named “myFolderLink” in the C drive that points to the “myFolder” directory in the D drive.

Terminal window
mklink /h "C:\myFileLink.txt" "D:\myFile.txt"

Creates a hard link named “myFileLink.txt” in the C drive that points to the “myFile.txt” file in the D drive.

Create a Junction

Terminal window
mklink /j "C:\junctionLink" "D:\myFolder"

Creates a junction named “junctionLink” in the C drive that points to the “myFolder” directory in the D drive.

Terminal window
mklink

Lists all symbolic links on the system.

Terminal window
mklink /h

Checks if a file is a symbolic link.

Terminal window
mklink /d "C:\myFolderLink"

Displays detailed information about the symbolic link “myFolderLink” in the C drive.

Terminal window
mklink /d /j "..\OtherFolderLink" "D:\myOtherFolder"

Creates a symbolic link with a relative path named “OtherFolderLink” in the current directory that points to “myOtherFolder” in the D drive.

Terminal window
mklink /d "C:\my Link" "D:\my Folder"

Creates a symbolic link with spaces in the name “my Link” in the C drive that points to the “my Folder” directory in the D drive.

To use the mklink command in Windows, execute the following command:

Terminal window
mklink --option <value>

The mklink command in Windows is used to create a symbolic link or a hard link to a file or a directory.

Terminal window
mklink /D C:\LinkToFolder C:\TargetFolder

To create a symbolic link using mklink, use the /D flag for directories or the /H flag for files.

Terminal window
mklink /D C:\LinkToFolder C:\TargetFolder

Yes, you can create a hard link using the mklink command by specifying the /H option.

Terminal window
mklink /H C:\LinkToFile.txt C:\TargetFile.txt

A symbolic link points to a file or directory by name, while a hard link points to the file’s data on the disk.

Terminal window
mklink /D C:\SymbolicLink C:\TargetFolder

You can validate a symbolic link in Windows by using the dir command with the /AL flag.

Terminal window
dir /AL C:\SymbolicLink

Yes, you can create a symbolic link for a network folder with mklink by specifying the network path.

Terminal window
mklink /D C:\NetworkLink \\Server\SharedFolder

Yes, you can delete a symbolic link created with mklink by using the del command followed by the link path.

Terminal window
del C:\SymbolicLink
  • Creating symbolic links
  • Creating hard links
  • Linking directories
  • Linking files