.net&管理员权限-如何在2种不同情况下嵌入清单文件 [英] .net & admin rights - how to embed manifest file for 2 different scenarios
问题描述
我有一个.net应用程序,它将安装在以两种不同模式运行的程序文件"下:
I have one .net application which would be installed under "program files" running in 2 different modes:
- "ADVANCED_MODE"和所有插件 已启用,应该会弹出UAC 以管理员身份运行
- "BASIC_MODE"只有几个插件 已加载,应该可以正常工作 用户
- "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
该如何解决此问题?
如果我嵌入清单文件(requireAdmin
设置为打开),它将不适用于BASIC_MODE.如果我不使用任何清单,则没有机会在ADVANCED_MODE中弹出UAC.如果我使用"asInvoker
"或"highestAvailable
",以普通用户帐户从程序文件"运行该应用程序时,会得到奇怪的效果:启动后立即关闭,没有任何崩溃.
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?
推荐答案
在清单中使用asInvoker,并在ADVANCED_MODE中启动您的应用程序时(并且您还不是管理员),请使用ShellExecute和"runas"动词.
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.
这些奇怪的影响"表明您的应用程序不能真正以非管理员身份运行(没有清单,您的应用程序将以诸如文件和注册表重定向之类的一些兼容垫片运行).您可以使用 LUA Buglight 和进程监视器查找标准用户错误...
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...
这篇关于.net&管理员权限-如何在2种不同情况下嵌入清单文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!