Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using mklink command with network drives

I have two network drives that I access through Windows 7: V:\ and T:\ I am trying to create shortcuts between the two that alphabetise with folders (rather than files), so I am using the mklink command:

mklink /d \Photos V:\Photos

which creates a symlink at C:\.

I can move the symlink around locally. However, when I try to move the symlink to a network location, it begins copy the actual files over rather than symlinking them.

I figure that if I can create a symlink of a network drive on a local drive, what's stopping me creating a symlink of a network drive on another network drive. Am I correct in assuming this?

Is there any way to designate the destination file path when creating symlinks with the mklink command? Or is there any way to move symlinks to a network drive at all?

like image 561
Sam Avatar asked Feb 06 '14 23:02

Sam


People also ask

Can you map a network drive from the command line?

“Net use” is a command line method of mapping network drives to your local computer. The full syntax for net use is available from Microsoft .

How do I create a symbolic link in Mklink?

If you want to create a soft link to a folder or directory, use the format mklink /D link target. The “/D” option creates a symlink to a directory. Creating a hard link also follows the same process. Use the same mklink link target command structure but with the “/H” option.


2 Answers

If you need to make a directory junction (using /J) on a network drive, you can first creation a directory (/D) symbolic link and then create a junction off of that, like so:

mklink /D D:\shareLink \\network\share
mklink /J D:\junctionLink D:\shareLink
like image 88
P. T. Avatar answered Oct 07 '22 16:10

P. T.


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

like image 43
Matthias Avatar answered Oct 07 '22 18:10

Matthias