Why can't I make a symbolic link (mklink) even when I'm an administrator

16

When I run mklink /D "C:\Users\bwilliams\AppData\Roaming\Sublime Text 2" "C:\Users\bwilliams\Dropbox\Sublime Text", I get this error `You do not have sufficient privilege to perform this operation.

Why not? I'm administrator, and just want to create a link in my own Users\bwilliams directory to another folder in my Users\bwilliams directory? What am I doing wrong here?

Thanks.

Ben

Posted 2012-03-19T13:32:22.470

Reputation: 316

Question was closed 2015-05-15T15:20:36.320

@mehaase Old comment, but... you can hose things with a poorly-placed junction, this is to protect from inadvertently doing that. The referenced, not at all a duplicate and I don't understand why the duplicate tag is still there today, question explains how to add that permission to a user. – EKW – 2016-08-14T15:19:20.780

2Hilarious. I'm trying to do the same exact thing -- sync dropbox settings on Windows -- and I'm completely stymied why creating symlinks is not a default privilege for average users. I own the source and the target, and they are both underneath my home directory. Why is this restricted?! – Mark E. Haase – 2012-04-24T12:57:53.647

2I was able to do this using mklink /J instead of mklink /D. Nothing has blown up... yet... – Mark E. Haase – 2012-04-24T13:15:43.790

Answers

12

You need to run mklink from an elevated shell (Right-click the Command Prompt shortcut, Run As Administrator).
If you are running mklink from an elevated shell, check the permissions on the directory and make sure there aren't any explicit Deny permissions set for the Administrators group.

Note: Make sure you're not trying to create a link where a directory containing files already exists, and are not accidentally creating a recursive set of links.

EKW

Posted 2012-03-19T13:32:22.470

Reputation: 1 030

I ran it as Administrator and now it give the error Cannot create a file when that file already exists. So I deleted the Dropbox Sublime Text directory and tried it again and got the same message. Do you know what's wrong? – Ben – 2012-03-19T20:12:59.493

@Ben The error is likely about the "Dropbox Sublime Text 2" directory, which is the link name being created. Make sure there's no folder or file with that name (there could be a file if you tried it without the /D at some point). – mtone – 2012-03-19T21:11:01.320

There is no such file or directory. And the only permissions thing that I can see is that "Special permissions" are not Allowed (or Denied) for Administrators, System, or my bwilliams user account. I can't seem to figure out how to "check" special permissions. – Ben – 2012-03-19T21:19:30.347

@Ben What is the Source Directory (The real directory) and what is the Target Directory (The symbolic directory)? I think you may be entering the parameters backwards. – EKW – 2012-03-19T23:36:59.920

@EKW, well, now I'm not sure. By default, the Sublime Text 2 program I'm using stores stuff in the AppData\Roaming\Sublime Text 2 directory. But I want to "trick" Sublime Text into thinking that the Dropbox's "Sublime Text" directory is actually the AppData\Roaming\Sublime Text 2 directory. Once linked correctly, all the files will actually live in the Dropbox\Sublime Text directory. – Ben – 2012-03-20T13:40:11.967

3It turns out the directory I needed to delete was the original AppData\Roaming\Sublime Text 2 Directory. makes sense now that I did it. – Ben – 2012-03-20T14:03:08.540

7

I ran into the same problems:

At first I got this error: You do not have sufficient privilege to perform this operation

And after retrying using an elevated cmd, I ran mklink /D linkToDir C:\temp\otherLink and received this error: Cannot create a file when that file already exists.

Turns out there was a (broken?) symlink there, marked as System:

attrib *

A  S  C:\temp\linkToDir

So FYI, check that there's not a Hidden (actually System) file using that name from a previously broken symlink creation.

That is what I wanted to highlight here.

enorl76

Posted 2012-03-19T13:32:22.470

Reputation: 272

2

I ran into the same problem and just managed to get it working. I was trying to force itunes to backup on another (larger) drive (C is an SSD).

Say you want to go from c:\dir1\dirToRedirect to d:\dirToRedirectTo, then:

Make sure dirToRedirect does not exist, because Windows is gonna create a link of the same name, which creates a naming conflict. So, delete dirToRedirect, create dirToRedirectTo, and run mklink /j "c:\dir1\dirToRedirect" "d:\dirToRedirectTo"

Tof

Posted 2012-03-19T13:32:22.470

Reputation: 21