user1748388
user1748388

Reputation: 23

CreateSymbolicLink equivalent to “mklink /J”?

Without admin privileges, I know I can create a symbolic link in command line:

mklink /J LinkPath OriginalResourcePath

In C++, I tried using CreateSymbolicLink; however, I got error "A required privilege is not held by the client." Is there a way to create a symlink/junction to a directory without admin privileges, equipvalent to mklink /j?

Thanks in advance!

Upvotes: 2

Views: 2086

Answers (2)

David Heffernan
David Heffernan

Reputation: 612794

What you are creating with mklink /j is not a symbolic link. It is an NTFS junction. You can create junctions without admin rights, but you need SeCreateSymbolicLinkPrivilege to create a symbolic link. And by default only admin tokens have SeCreateSymbolicLinkPrivilege.

So, you need to create a junction. This Code Project article shows you how to do that: http://www.codeproject.com/Articles/194/Windows-2000-Junction-Points

Upvotes: 2

ixe013
ixe013

Reputation: 10171

Yes, it is possible. Junction and GnuWin32's ln work well on Windows, I use them all the time without elevation.

But regular file system access check apply. Your program must have write access to the directory to create a link.

Upvotes: 0

Related Questions