47

I was trying to use mklink command in cmd (I have Windows 7 OS) I was logged on as administrator, but I got:

You do not have sufficient privilege to perform this operation.

I used the same command in Vista, it worked OK. Any ideas why it does not work in Windows 7?

Wasif
  • 7,984
  • 2
  • 19
  • 32
ToZo99
  • 471
  • 1
  • 4
  • 3

9 Answers9

37

Try explicitly running the CMD shell as administrator. If that doesn't help, then try the runas command.

runas /user:administrator "mklink args"

Quotes around the mklink command and its arguments are required.

Wasif
  • 7,984
  • 2
  • 19
  • 32
Michael Pryor
  • 2,616
  • 5
  • 27
  • 38
  • 29
    Symlinks are too dangerous for a normal user. LOL. I wish I could understand the considerations behind this. :-( – Notinlist Apr 14 '11 at 13:34
  • 2
    My user is an administrator (there is no user called "administrator" on this machine.) but I still get "You do not have sufficient privilege to perform this operation." – Jonathan Hartley Jan 08 '12 at 18:35
  • 5
    This answer, although helpful advice in the general case, seems to be exactly the opposite of the behaviour I'm observing: mklink only works for me when my user is *not* an administrator. Puzzling. – Jonathan Hartley Jan 09 '12 at 00:41
  • what to do if you don't have a login password? it is asking for one and if I leave blank it tells me blank password error... – ecoe Aug 17 '14 at 18:21
  • 1
    so, after finding out winblows broke the years and years old 'cd' syntax for cd /D, you get to type in the mklink syntax in the horrible contraption called 'cmd.exe' to find out you don't have privileges nad had to run as administrator first. Winblows sysadmin, the horror aaargh. – Michahell Jan 18 '16 at 18:23
  • Didn't work. Instead I had to: `runas /user:administrator cmd`, and then in that new window, run the `mklink` command. Argh! – Ross Smith II Apr 29 '16 at 13:55
  • @JonathanHartley your administrator account likely has different name and your account is the admin, so when you runas administrator, you ironically switch from admin priviledges. Find your current (admin) account by `echo %username%` – Jan Turoň Oct 07 '20 at 11:38
16

Type CMD, you will see CMD.exe in the list at start menu.

Right click on it, select "Run as Administrator"

Wasif
  • 7,984
  • 2
  • 19
  • 32
Eric Yin
  • 369
  • 3
  • 9
14

In response to this not working for administrator accounts, I believe that Configuring symlink support in Windows 7 is relevant.

After giving “Everyone” the privilege “Create symbolic link”, please reboot (or log off) and log in as a standard user, a user who is NOT a member of group “Administrators”. You should be able to create a symbolic link using mklink command in a directory where user has write permissions.

The reason a member of “Administrators” cannot create symbolic link is because “Create symbolic link” privilege is removed from the filtered token since user is a member of “Administrators” group. Section “Access Token Changes” of article at link http://msdn.microsoft.com/en-us/library/bb530410.aspx describes in more details on how filtered token is created.

Wasif
  • 7,984
  • 2
  • 19
  • 32
Mike
  • 241
  • 2
  • 3
11

If, for some reason, you cannot elevate your account to an administrator (eg. you're on a work computer), and you're trying to link a directory, try creating a junction instead of a hard/soft symbolic link. The source folder can be absolute or relative.

mklink /J linkedfolder sourcefolder
Wasif
  • 7,984
  • 2
  • 19
  • 32
hughes
  • 1,792
  • 3
  • 18
  • 23
  • 2
    Thank you. This worked for me as I do not have admin on my work pc and needed to link cygwin directories and windows directories. – dukevin Aug 06 '19 at 20:41
11

First, make sure you've granted the "Create symlinks" permission to the relevant users, as detailed here.

Bizarrely, the mklink command will not work for me if my user is an administrator. It gives:

You do not have sufficient privilege to perform this operation.

To make it work, I then need to either remove my user from the administrators group, or run mklink from a cmd which has been run as a non-Administrator user such as guest:

runas /user:guest cmd

(Enable the guest account if it isn't already)

Using this latter method, you'll also have to temporarily grant permissions for 'guest' account to modify the location you're creating the Symbolic link in, which in my case was my home directory, causing a flurry of error dialogs, but they seemed harmless.

Wasif
  • 7,984
  • 2
  • 19
  • 32
Jonathan Hartley
  • 1,006
  • 13
  • 25
  • 1
    It doesn't seem to work (I blame Microsoft). The `runas` command asks for the password of the specified user, even if the account doesn't have one. If you leave it blank (hit enter), it errors out. If the account does have a password and you type it in, then I end up with `the system cannot find the file specified`. Starting a cmd as admin, navigating to the target dir and creating the symlink with your own account suddenly appears so easy... – CodeManX Apr 15 '16 at 10:02
1

In a WIN+R (Run.....) box, type cmd and hit CTRL+SHIFT+ENTER to run Command Prompt as Administrator.

Wasif
  • 7,984
  • 2
  • 19
  • 32
0

Run "CMD" Command Prompt with "Administrator Privileges":

  • Start > Search for CMD
  • Right Click and chose "Run as Administrator"
  • Click Yes on "Do you want to allow this app to make changes to your device?"

And run you command again.

Chaos_99
  • 918
  • 1
  • 12
  • 29
0

Check to see the "Secondary logon" service isn't disabled.

Wasif
  • 7,984
  • 2
  • 19
  • 32
surfasb
  • 22,452
  • 5
  • 52
  • 77
  • 10
    As a highly valued Super User, I suggest you revisit this answer and [add more detail](http://meta.superuser.com/questions/5177/what-do-we-do-with-low-quality-answers-from-high-rep-users). – James Mertz Jul 27 '12 at 21:54
-3

If not installed, please consider installing Microsoft.NET framework 2.0 or the service packs that go with it.

It worked for me!

Wasif
  • 7,984
  • 2
  • 19
  • 32