如何使用 ProcessStartInfo 以最低执行级别运行
我有一个使用 AsInvoker
清单运行的应用程序,它使用 ProcessStartInfo
运行另一个使用 HighestAvailable
清单的应用程序(在我的例子中是以管理员身份运行,我收到 UAC 提示)第一个应用程序然后退出。
然后第二个应用程序使用 ProcessStartInfo 再次运行第一个应用程序,这次它以管理员身份运行(没有 UAC 提示)我想这是正确的,因为它是 AsInvoker 并且它是从以管理员身份运行的应用程序调用,但我实际上希望它在没有管理员权限的情况下运行 - 或者更正确地以尽可能低的执行级别运行它
,我知道您可以使用 ProcessStartInfo.Verb = "runas" 上升,但你能下降吗?
I have an application that runs using as AsInvoker
manifest, this uses ProcessStartInfo
to run another application that is using a HighestAvailable
manifest (in my case this runs as Admin and I get the UAC prompt) the first app then quits.
The second app then uses ProcessStartInfo
to run the first app again, this time it runs as admin (no UAC prompt) I guess this is correct because it is AsInvoker
and it is being invoke from an application that is running as admin, but I actually want it to run without Admin rights - or more correctly run it with the lowest possible execution level
I know you can use ProcessStartInfo.Verb = "runas"
to elevate but can you descend?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
不,你不能“回去”(这个网站上有几个答案和外部教程声称不然,但它们在某些情况下都有问题,MS 员工的这个答案确认这是案例)
您唯一真正的选择是使用 AsInvoker bootstrapper /parent 进程可以启动未提升的进程。 (如果引导程序启动提升,即使这也会失败,但在这些情况下,用户手动选择以管理员身份运行)
No, you cannot "go back down" (There are several answers on this site and external tutorials that claim otherwise, but they all have problems in certain scenarios, this answer from a MS employee confirms that this is the case)
Your only real option is to use a AsInvoker bootstrapper/parent process that can launch unelevated processes. (And even this will fail if the bootstrapper is started elevated, but in those cases the user manually chose to run as admin)
@Anders 是说你不能降低自己的流程水平,这是正确的。但OP正在询问是否从提升的进程启动非提升的进程。
根据 Aaron Margosis(也是微软员工,并不是说我在鄙视我心目中的英雄拉里)可以做到。 MVP 为 Aaron 的本机代码编写了 一个托管包装器。
小心使用。
@Anders is saying you can't level your own process back down, and that's right. But the OP is asking about launching a non-elevated process from an elevated one.
According to Aaron Margosis (also a Microsoft employee, not that I'm dissing Larry who is a hero of mine) that can be done. An MVP has written a managed wrapper for Aaron's native code.
Use with care.