如何使用java.nio.Files创建软符号链接 [英] How to create Soft symbolic Link using java.nio.Files

查看:470
本文介绍了如何使用java.nio.Files创建软符号链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用以下命令在Windows上创建符号链接:

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

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

从Groovy并使用Runtime.getRuntime().exec()方法

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

它工作正常,但我想使用 java.nio.Files.createSymbolicLink()方法执行相同的操作.但是我总是得到相同的错误消息:

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.

mklink/J命令适用于当前用户,我想避免提升特权

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

推荐答案

在Windows(W7)中,您可以将用户添加到可以使用安全策略创建符号链接(无需禁用UAC)的用户列表中.

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

  • 运行secpol.msc
  • 转到Security Settings|Local Policies|User Rights Assignment|Create symbolic links
  • 添加您的用户名.
  • 重新启动会话.
  • Run secpol.msc
  • Go to Security Settings|Local Policies|User Rights Assignment|Create symbolic links
  • Add your user name.
  • Restart your session.

这篇关于如何使用java.nio.Files创建软符号链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆