Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
661 views
in Technique[技术] by (71.8m points)

windows - How to create Soft symbolic Link using java.nio.Files

i'm creating symbolic links on Windows using a command like this :

cmd /c mklink /J "${linkName.canonicalPath}" "${targetFolder.canonicalPath}"

From Groovy and using Runtime.getRuntime().exec() method

It's working fine but i want do the same using java.nio.Files.createSymbolicLink() method. But I always obtain the same error message:

java.nio.file.FileSystemException: A required privilege is not held by the client.

The mklink /J command works for the current user and i want avoid elevate privileges

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

With Windows (W7), you can add a user to the list of who may create symbolic links (without disabling UAC) using security policies.

  • Run secpol.msc
  • Go to Security Settings|Local Policies|User Rights Assignment|Create symbolic links
  • Add your user name.
  • Restart your session (logoff+login, no need to restart Windows).

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...