77

I am a Linux guy and as such I am very lost when I try and do anything is Windows. I am trying to create the following link:

mklink /d C:\backup\data \\myth\backup\data

But I do not have sufficient privilege to preform this operation. How do I get sufficient privileges in Windows 7?

UPDATE:

Right clicked on C:\backup\data and changed the permissions to full access for authenticated user, restarted the machine and tried the command again with no luck. Anyone have any further suggestions?

stephenmm
  • 1,297

7 Answers7

130

As stated here,

Creation of symbolic links requires the SeCreateSymbolicLinkPrivilege (“Create symbolic links”), which is granted only to administrators by default (but you can change that using security policy).

To change the policies:

  1. Right click on StartRun and launch secpol.msc.

  2. Open Security Settings → Local Policies → User Rights Assignment and select Create symbolic links (that represents SeCreateSymbolicLinkPrivilege).

enter image description here

  1. Double-click on the item and add yourself (or the whole Users group) to the list.

The changes will apply when you log out and log in again.

T.Todua
  • 4,053
Hugh Allen
  • 10,120
22

I just discovered that I can create a 'Junction' even when I can't create a symlink:

mklink [/D] /J junctionname filename

where /J indicates 'create a junction', and the /D is, I believe, for if the named file is a directory. (my user is currently an administrator)

However, a junction to a 'bat' file doesn't seem to be executable, so this isn't actually any use.

Does anyone understand why this is, or how it can be fixed to provide an alternative approach to the OP's problem?

14

I found only a non administrator can do it. Add non administrator to create symbolic links and runas non administrator. You'll have to add a person of with non admin privileges. Then you give permission to the target for the non admin, so he can do the runas mklink.

4

The above solutions didn't work for me because not only could I not create a "guest" user on my machine, I can't possibly ask all the users of my tools to do so too on their machines. Nor is it reasonable to require they use Administrator consoles.

My solution is to use: elevate.cmd and elevate.vbs

  1. Download from: http://technet.microsoft.com/en-us/magazine/2008.06.elevation.aspx
  2. Put those two files on your system path (or somewhere convenient on the network)
  3. elevate.cmd cmd /c "cd /d LINK_DIR && mklink /D LINK_NAME LINK_TARGET_PATH"

Cons: elevate.cmd returns immediately but answering the UAC dialog takes time. This forced me to add a "did you ok the UAC dialog yet?" question to my script. It is possible to skip "elevate.cmd" by checking the exit code for the following command: whoami /groups | find "S-1-16-12288" (exit code 0 means you have an Adminstrator console).

Denkkar
  • 41
2

Came across this problem today as well. I had a NAnt build task trying to create symbolic links on a computer. Was getting rejected for lack of privileges. I found this post which helped solve my problem: http://josh.mainelan.net/tag/mklink/.

The relevant section:

  1. Bring up your run box, type “secpol.msc” and click OK.
  2. Navigate under the Security Settings \ Local Policies \ User Rights Assignment folder.
  3. Find “Create symbolic links” and add the Users group to it.

I think you need to restart your computer or something after doing this.

Run5k
  • 16,463
  • 24
  • 53
  • 67
Matt
  • 2,677
1

Run the command prompt as administrator to execute this command.

Type cmd (or command) in the start menu and right click on it and choose "run as an administrator".

Now any command that you execute will be executed with administrator privileges.

teknikqa
  • 422
-6

I'd recommend Ultimate Windows Tweaker. Use it to Select "Show Take Ownership" to get around the permissions issue, and "Show Open Command Window Here" to open command prompt at the correct folder.

alt text

Gareth
  • 19,080