Creating a symbolic link to mapped network drive in Windows

36

14

I am having an issue creating a symbolic link on Windows 7 Ultimate. I want to map a folder from a mapped network drive into My Documents.

mklink /D "C:\Users\Vegard\Documents\Virtual Machines" "Z:\Virtual Machines" returns You do not have sufficient privilege to perform this operation..

Z:\Virtual Machines is set to be available offline, but I am online when I am trying this.

This is what I've tried (as suggested here):

  1. Using Local Security Policy to add my user to Local Polices\User Rights Assignments\Create symbolic links, and rebooting. No luck.

  2. Running cmd.exe as an Administrator, but then I cannot see the mapped network drive at all. I can however create symbolic links on the drive.

  3. Using fsutil to change symlinkevaluation, to set R2L:1 (even though it seem to me I want L2R, which is already enabled).

  4. Using full UNC path of the shared folder does not work either (The syntax of the command is incorrect. when run as an administrator, You do not have sufficient privilege to perform this operation. when run as a normal user).

Output of fsutil behavior query symlinkevaluation:

C:\Windows\system32>fsutil behavior query symlinkevaluation
Local to local symbolic links are enabled.
Local to remote symbolic links are enabled.
Remote to local symbolic links are enabled.
Remote to remote symbolic links are disabled.

Any ideas?

Vegard Larsen

Posted 2010-11-14T21:20:10.063

Reputation: 1 039

As I mentioned below, this is because an elevated prompt does not have the foldershares mapped to it. Try a cd z:\ and you'll get an error. run cmd as a user and see that the folder is mapped. – surfasb – 2011-12-23T23:04:25.433

Answers

2

My solution became to disable User Account Control, reboot, then create the symlinks as my own user, then re-enabling UAC and rebooting again.

Rather unfortunate if I need to create further symlinks at a later stage, but it does work, it is just very inconvenient.

Vegard Larsen

Posted 2010-11-14T21:20:10.063

Reputation: 1 039

5This is because the foldershare is mapped under the user account. When you launch cmd as admin, it launches as an admin account, and does not have the foldershares mapped. – surfasb – 2011-12-23T23:03:03.203

49

Run cmd as administrator and use UNC path.

The following command worked for me as administrator:

mklink /D C:\temp11111 \\server\share\foldername\

And also check whether your command contains appropriate quotes (").

jhamu

Posted 2010-11-14T21:20:10.063

Reputation: 1 269

9

This is a old thread, but still want to clarify that you can create symbolic links like this:

Your user account has some security policies on them by default which can be disabled, through secpol.msc. Go to the Run dialog and type:

secpol.msc
  • Navigate to: Local Policies > User Rights Assignment
  • Double click: Create Symbolic Links
  • Add your username to the list, click OK
  • Log off

When you log back in, run cmd with admin privileges. Now you should be able to run mklink commands like this with no problems:

mklink /d %userprofile%\music \\server\music

Note: Make sure the directory you're trying to link to exists or hasn't been moved or deleted, prior to linking.

reconx86

Posted 2010-11-14T21:20:10.063

Reputation: 91

Why is running as administrator necessary? If the user has the Create Symbolic Link privilege, one would think no such elevation would be required – kreemoweet – 2015-09-05T03:54:05.533

1Note; secpol.msc doesn't exist in the home version of win7. – JonoRR – 2014-05-28T07:59:01.540

2

If you are doing this in Powershell, you'll need to open CMD first:

CMD /C MKLINK /D C:\local\path \\UNC\path\folder

The /C argument tells CMD to run the command in the string and then exit.

music2myear

Posted 2010-11-14T21:20:10.063

Reputation: 34 957

1

You need to enable local to remote links by running this command with elevated rights: fsutil behavior set SymlinkEvaluation L2R:1

Also you can enable this with your local or group policy: Computer\System\Filesystem\Selectively allow the evaluation of a symbolic link --> allow local to remote

Best regards,

Matthias

Matthias

Posted 2010-11-14T21:20:10.063

Reputation: 21

-1

You cannot do symbolic links in networks and mapped drive as source, you can only use it as target and the source is your local drives

you cannot do like this:

Mapped Drive is Drive Z:\ Target (Local drive or Network)

Mklink /d z:\SourceFolder c:\Target Mklink /d z:\SourceFolder F:\SharedNetworkFolder

they are error and cannot used as symbolic links

only from Local to network and Local to Local only will work in symbolic links

Mark

Posted 2010-11-14T21:20:10.063

Reputation: 1