How to create a hard link in Windows using mklink command?

I've no problem in creating junctions and symbolic links through mklink, but can't create hard link using this command. It returns "Access denied", have tried on both Windows 7 and 8.1 on different machines, cmd started with administrative privileges.

D:\>mklink /d /h dirA dirB

Of course dirB exists. Is there something I should do to run this command without error?


I'm pretty sure you can't create a hard link to a folder, only files. Symbolic links /D and junctions /J would work for folders though.

Also when creating hard links, keep in mind that you cannot create links between 2 different drives (even on the same physical hard drive).

A short explanation from another SU answer:

A hard link is a file system feature that cannot cross a file system boundary. You can't hard link files on C: to D: because they are separate file systems. They might each contain the same type of file system (eg. NTFS) but they are separate file systems.


As David commented in reply to Braden, Junctions may not technically be "hard folder links," but I think one could say that "/J is harder than /D"

Case in point is that if you mklink /D "..\link_dir" "existing_dir", you will not be able to cd into "link_dir". However, you can cd if you use /J instead.


No you CAN make a hard link to a folder/directory. It's called a junction. mklink /J

https://msdn.microsoft.com/en-us/library/windows/desktop/aa365006(v=vs.85).aspx http://www.sevenforums.com/tutorials/278262-mklink-create-use-links-windows.html

Also, mklink /D creates a directory symbolic link, not a hard link. In practice, symbolic links are "fancy shortcuts" to files and folders, while hard links are sort of like a "file sync" for files only, where the "shortcut" is a "twin" of the target file; make changes to one, and you make changes to both...but in reality there is actually only one file physically on the drive, so if the target file is 500MB in size, only 500MB are being used. JUNCTIONS are hard links for folders and function the same as hard links.