你怎么去提升一个子进程权限 [英] How do you de-elevate privileges for a child process

查看:223
本文介绍了你怎么去提升一个子进程权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道如何使用管理员权限从过程中使用启动一个进程:

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

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

其中P​​ROC是的System.Diagnostics.Process。但是,我们如何做相反?

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

如果您所在的进程已经升高,你怎么不启动管理员权限的新的进程?更准确地说,我们需要用相同的权限级别Windows资源管理器启动新的进程,因此,如果UAC没有任何变化是禁用的,但如果UAC已启用,但我们的进程正在运行升高,我们需要执行某种操作未升高因为我们要创建一个虚拟驱动器,如果它与提升的权限创建和Windows资源管理器运行unelevated也不会显示出来。

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.

推荐答案

我们结束了使用此code项目本文的示例:的高海拔可能不利于你的应用程序:如何在安装结束时启动未提升的过程

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的是相当薄弱,所以我没有看太多到实际执行,只是它的使用。证实它在Vista和Win7的作品都x86和x64(至少对我们来说,x86和x64需要在安装时和适当的一个使用的检查不同的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天全站免登陆