您如何降低子进程的权限 [英] How do you de-elevate privileges for a child process

查看:21
本文介绍了您如何降低子进程的权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何使用以下方法从进程中启动具有管理员权限的进程:

I know how to launch a process with Admin privileges from a process using:

proc.StartInfo.UseShellExecute = true;
proc.StartInfo.Verb = "runas";

其中 proc 是 System.Diagnostics.Process.但是如何做相反的事情呢?

where proc is a System.Diagnostics.Process. But how does one do the opposite?

如果您所在的进程已经被提升,您如何在没有管理员权限的情况下启动新进程?更准确地说,我们需要以与Windows资源管理器相同的权限级别启动新进程,因此如果禁用UAC则没有变化,但如果启用了UAC,但我们的进程正在提升运行,我们需要执行未提升的某些操作因为我们正在创建一个虚拟驱动器,如果它是使用提升的权限创建的,并且 Windows 资源管理器在未提升的情况下运行,它将不会显示.

If the process you're in is already elevated, how do you launch the new process without admin privileges? More accurately, we need to launch the new process with the same permission level as Windows Explorer, so no change if UAC is disabled, but if UAC is enabled, but our process is running elevated, we need to perform a certain operation un-elevated because we're creating a virtual drive and if it's created with elevated permissions and Windows explorer is running unelevated it won't show up.

随意将标题更改为更好的内容,我想不出一个好的描述.

Feel free to change the title to something better, I couldn't come up with a good description.

推荐答案

我们最终使用了这篇代码项目文章中的示例:高提升可能对您的应用程序不利:如何在安装结束时启动非提升进程

We ended up using the sample from this Code Project article: High elevation can be bad for your application: How to start a non-elevated process at the end of the installation

到目前为止它似乎可以工作,我认为它注入了 RunDll32.exe,我的 C++/Win32 相当弱,所以我没有过多研究实际实现,只是它的使用.确认它适用于 x86 和 x64 的 Vista 和 Win7(至少对我们来说,x86 和 x64 需要不同的 dll,在安装时检查并使用正确的 dll).

It seems to work so far, I gather it injects into RunDll32.exe, my C++/Win32 is fairly weak so I didn't look too much into the actual implementation, just it's use. Confirmed that it works in Vista and Win7 both x86 and x64 (at least for us, x86 and x64 require different dll's which is checked for at install time and the proper one is used).

这篇关于您如何降低子进程的权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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