0
votes

I am running C# code from my web application that needs to create a Directory Junction on a remote machine, with a target folder which is also on the same remote machine.

I am using JunctionPoint.cs library from https://www.codeproject.com/Articles/15633/Manipulating-NTFS-Junction-Points-in-NET.

I am using UNC paths to create the symlink and the destination folders, from my web server. The directory junction does get created. But when I click on it, it says invalid Label, Directory or volume, which I am guessing is because of the UNC Path Target.

I cannot use the CreateSymbolicLink() function from C# as it doesn't create the directory junction.

Can you please guide me what's the best way to achieve this?

Thanks much!

2

2 Answers

0
votes

A Directory Junction (symbolic link) does not allow remote links by default. You need to enable this group policy on the server:

Computer Configuration\Administrative Templates\System\NTFS File System\Selectively Allow The Evaluation Of A SymbolicLink

Or you can use the fsutil tool to enable remote to remote junctions:

fsutil behavior set SymlinkEvaluation R2R:1
0
votes

Just to complete this thread, I ended up using WMI objects (System.Management) within my c# web application, to run the mklink /j dos command on the remote machine. It almost seemed like we need to be local to the machine to fire that command.