.net & admin rights - how to embed manifest file for 2 different scenarios
Asked Answered
I

1

0

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?

Integrated answered 10/5, 2011 at 15:39 Comment(0)
T
3

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

Thorpe answered 10/5, 2011 at 15:57 Comment(2)
Thank you for your answer. So, at least there is an explanation for these 'strange effects'. Although I cannot do what you suggested since my app accepts only one instance running on the system.Integrated
@Cristi: You can do the elevation stuff before checking for the mutex or whatever your instance check is doing...Thorpe

© 2022 - 2024 — McMap. All rights reserved.