问题
I have one .net application which would be installed under "program files" running in 2 different modes:
- "ADVANCED_MODE" with all plugins enabled which should pop-up the UAC to run as administrator
- "BASIC_MODE" with only few plugins loaded which should work as normal user
What to do to solve this case?
If I embed a manifest file (requireAdmin
set on), it will not work for BASIC_MODE. If I don't use any manifests, then I don't have the chance to popup the UAC in ADVANCED_MODE. If I use "asInvoker
" or "highestAvailable
" I get strange effects when I run the app from Program Files as normal user account: it closes immediately after startup without any crash.
What would you do? What are my options?
回答1:
Use asInvoker in your manifest and when your app is started in ADVANCED_MODE (and you are not already admin), start a new instance of your app with ShellExecute and the "runas" verb.
These "strange effects" indicate that your app can't really run as non-admin (Without a manifest your app will run with some compatibility shims like file & registry redirection) You can use the Microsoft Application Compatibility Toolkit, LUA Buglight and Process Monitor to look for standard user bugs...
来源:https://stackoverflow.com/questions/5952673/net-admin-rights-how-to-embed-manifest-file-for-2-different-scenarios