.net & admin rights - how to embed manifest file f

2019-08-19 04:32发布

问题:

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