53

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
  • 9,176
ToZo99
  • 531

9 Answers9

38

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
  • 9,176
16

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

Right click on it, select "Run as Administrator"

wasif
  • 9,176
Eric Yin
  • 369
15

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
  • 9,176
Mike
  • 251
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
  • 9,176
hughes
  • 1,792
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
  • 9,176
1

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

wasif
  • 9,176
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
  • 1,008
0

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

wasif
  • 9,176
surfasb
  • 22,896
-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
  • 9,176