Using windows mklink for linking 2 files
Asked Answered
G

2

2

I'm trying to find the equivalent of *nix symlink on windows, and started using mklink. The issue is that, as a normal user (not admin), I can link to a folder with the "/J" option, but I cannot link to a file. I managed to do it as administrator, but I need it as standard user.

Why only Administrators can create file links on Windows? Is there a workaround?

Galloot answered 17/7, 2011 at 7:59 Comment(3)
By the way, always prefer mklink /D over mklink /J. Windows explorer will delete the entire contents of a junction (the latter) whereas when deleting a directory link (the former) it will just remove the link.Fanti
@SoftwareMonkey This is not so in Windows 7. Only the link is removed. (I tested it.)Wodge
@Davor: You're right; was definitely the case in XP, but then XP didn't really "know" about junctions in the O/S - I used the SysInternals junction.exe to create NTFS junctions.Fanti
D
6

You need the SeCreateSymbolicLinkPrivilege to create a symbolic link, which I don't think users get by default.

-scott

Delicacy answered 18/7, 2011 at 14:57 Comment(4)
Thanks that helped. From the info I found based on this I compiled this text: "Creating symlink on Windows Vista and Windows 7 don't require administrator privilege per se, but SeCreateSymbolicLinkPrivilege. There are 2 ways to give this privileges to users: 1) Start gpedit.msc, go down to "Windows Settings"->"Security Settings"->"Local Policies"->"User Rights Assignment", then find "Create symbolic links" and add whatever users and groups you want. 2) If you have cygwin running: "editrights -a SeCreateSymbolicLinkPrivilege -a user" should work."Galloot
I tried to add this privileges to myself, and everyone but still get: C:\Users\freds>mklink test-6.txt test.txt You do not have sufficient privilege to perform this operation. (And it works great as administrator...)Galloot
Note: You need to log off and back on for the privilege to take effect.Fanti
Where I can find SeCreateSymbolicLinkPrivilege? Where "Windows Settings"?Frown
P
1

Had problems creating links on Windows 10 Home Edition - I was getting "You do not have sufficient privilege to perform this operation". In the end, I was able to create a soft link using power shell with this command:

   cmd /c mklink /J c:\path\to\symlink d:\target\directory

The above creates a soft link but does not work for symbolic links (/D option). Soft link was sufficient for my needs (and I didn't have to install gpedit.msc).

Preliminary answered 8/9, 2020 at 19:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.