[英]C# Win. Form - Elevate Applications Privileges Programmatically
I have searched a lot on this topic on internet but can find a decent solution to it. 我在互联网上搜索了很多有关此主题的内容,但可以找到一个不错的解决方案。
I want my application to get and set Environment Variable values as soon as it is started but it seems that i need administrator privileges for it. 我希望我的应用程序一开始就获取并设置环境变量值,但似乎我需要管理员权限。 Now the problem is that i cannot set the EXE to "Run As Administrator" because on starting the application, it always prompts for admin permission.
现在的问题是我无法将EXE设置为“以管理员身份运行”,因为在启动应用程序时,它总是提示输入管理员权限。
Is there any way to avoid the admin privileges prompt programatically ? 有什么方法可以通过编程避免管理员特权提示 ?
Here are the following articles i tried which didn't work :- 这是我尝试过的以下文章,这些文章无效:-
Is there any way to avoid the admin privileges prompt programatically?
有什么方法可以通过编程避免管理员特权提示?
Yes, but you should append keys to registry as shown in second link article. 是的,但是您应该将注册表项附加到注册表,如第二个链接文章中所示。 And it's not a promt disable, it's UAC disable.
这不是promt禁用,而是UAC禁用。 If UAC is enabled, windows will always ask you for admin rights, even you try to get them programmatically.
如果启用了UAC,则即使您尝试以编程方式获取Windows,Windows也会始终询问您管理员权限。
And what about Env Vars, they only divided on groups for your user and for all users, not admin. 而Env Vars呢,它们只为您的用户和所有用户划分组,而不是管理员。 So you must be able to access all of shared env vars
因此,您必须能够访问所有共享的环境变量
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.