开发者

How to use ProcessStartInfo to run at lowest execution level

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 u开发者_开发问答ses 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?


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 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜