如何使用标准用户检索连接点或符号链接的目标
我试图获取程序中连接的目标,但我设法做到这一点的唯一方法是:
- 请求备份权限
- p-invoke CreateFile 使用特殊参数来获取文件/目录的句柄。
- DeviceIoControl 调用以获取目标。
第一步不适用于普通用户帐户,因为他们没有备份权限,而且我不想每次执行此操作时都获得 UAC 用户同意窗口。
我认为这是可行的,因为正常的“dir /A:L”命令可以解析链接的目标。
I am trying to get the target of a junction in my program, but the only way I managed do it is:
- Requesting Backup privileges
- p-invoke CreateFile with special parameters to get a handle to the file/dir.
- DeviceIoControl call to the get the target.
The 1st step will not work with normal user accounts, because they have no Backup privileges, and I don't want to get the UAC User Consent window every time I do this.
I think this is doable somehow, because a normal "dir /A:L" command resolves the target of the links.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我认为 stackoverflow 中的这个答案会对您有所帮助?
如何以编程方式访问Windows 符号链接的目标路径?
应该可以通过 ac# 程序中的 DllImport 属性包含对该函数的引用。
所需的句柄可从 FileStream 实例。有点有趣的是它被标记为过时,但也许警告说明了您还可以做什么。
I think that this answer in stackoverflow would help you?
How do I programmatically access the target path of a windows symbolic link?
It should be possible to include a reference to the function via DllImport Attribute in a c# program.
The required handle is obtainable from the a FileStream instance. Somewhat funny that it is marked as obsolete, but maybe the warning states what else you can do.