I need to change the behavior of my application depending on user privileges:
- When my application can run as Administrator
- 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.
精彩评论