44

From command prompt with Administrator privilages:

c:\>mklink /h c:\dirA c:\Users\Piotr\dirB
Access is denied.

I'm on Vista x64. Using /j or /d instead of /h works. What's the problem?

Related:

Access is denied error, when I mklink on Windows 7.

Piotr Dobrogost
  • 5,402
  • 14
  • 57
  • 78
  • Not sure if this is what you're after, but I tried mklink w/o any flags to try to link a directory and it didn't give me what I wanted. I tried using the \D flag and that seemed to work (not sure if that's different than \d or the default, which some ms docs said was 'symbolic'). – jinglesthula Jul 02 '14 at 16:12

3 Answers3

55

Hard links can only be used for files, not directories.

References: MSDN: Hard Links and Junctions, <1>, and <2>

David d C e Freitas
  • 4,511
  • 4
  • 27
  • 35
16

You can use the /j switch to create a directory soft link. Be careful with the del command. To remove link to directory use the rmdir command, as del will delete all files in the directory the link points to.

DavidPostill
  • 153,128
  • 77
  • 353
  • 394
labiol
  • 169
  • 1
  • 2
0

I had the same issue: check that the file or folder that you are trying to create doesn't already exist (c:\dirA).

David d C e Freitas
  • 4,511
  • 4
  • 27
  • 35