非提升进程是否可以将文件复制到受保护的目录? [英] Is there a way an NON-elevated process can copy a file to a protected directory?

查看:21
本文介绍了非提升进程是否可以将文件复制到受保护的目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当它准备好复制文件时,我可以要求用户进行提升.需要进行复制的程序无法运行提升(它丢失了许多重要的环境变量,我无法更改它的启动方式).我的后备方案是让它产生一个具有高程的进程,该进程实际上会进行文件复制,但我不想在我正在处理的内容中添加另一个 exe.

解决方案

使用 COM Elevation Moniker 实例化 IFileOperation shell 接口,然后通过该接口完成的所有文件操作都将被提升,而无需提升调用进程,也不必创建单独的 EXE/进程来处理文件访问.>

I am fine with it asking the user for elevation when it is ready to copy a file. The program that needs to do the copying cannot run elevated (it looses many important environment variables and I am not in a position to change the way it is started). My fallback will be to have it spawn a process with elevation that actually does the file copy, but I would prefer not to have to add yet another exe to what I am working on.

解决方案

Use the COM Elevation Moniker to instantiate the IFileOperation shell interface, then all file operations done with that interface will be elevated without having to elevate the calling process, or having to create a separate EXE/process to handle the file access.

这篇关于非提升进程是否可以将文件复制到受保护的目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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