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

查看:27
本文介绍了如何使用 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
  • 转到安全设置|本地策略|用户权限分配|创建符号链接
  • 添加您的用户名.
  • 重新启动您的会话(注销+登录,无需重新启动 Windows).

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

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