开发者

Run As Administrator if possible, if not: run with limited privileges?

I need to change the behavior of my application depending on user privileges:

  1. When my application can run as Administrator
  2. When my application has limited privileges

Since "requireAdministrator" is embedded within the manifest, the same .exe can't work on (1)开发者_如何学Go and (2) at the same time.

What's the best way to deal with this issue? I am planning to pack two executables (one with "requireAdministrator") and decide which one to run. Someone have other suggestions?


You can use a manifest that asks for highestAvailable instead of requireAdministrator or asInvoker. This will elevate if a person who can just consent to elevating is running it, but won't if it's someone who would need the OTS prompt and entering an admin id and password. I don't care for it myself, since you can't write your code in confidence knowing whether you have the privileges or not. But this is how to achieve what you're asking for.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜