如何为Windows应用程序C#禁用uac [英] How to disable uac for windows application C#

查看:266
本文介绍了如何为Windows应用程序C#禁用uac的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序以管理员身份运行,但总是要求popup在系统中打开。我通过编程禁用uac,但是某些应用程序无法正常工作。

我想在应用程序启动时停止弹出消息而没有uac禁用。



我尝试了什么:



我的应用程序以管理员身份运行,但总是要求popup在系统中打开。我使用编程禁用uac但是一些应用程序无法正常工作。

i想要在没有uac禁用的应用程序启动时停止弹出消息。

My application runs as administrator but always ask popup for open in system. I am disable uac with programing but some of the application not working.
I want to stop popup message when application start without uac disable.

What I have tried:

my application run as administrator but always ask popup for open in system .i am disable uac with programing but some of the application not working.
i want to stop popup message when application start without uac disable.

推荐答案

你不能,那是整个想法。

如果您的应用需要管理员访问权限,则必须询问用户是否批准此操作:其他任何内容都允许任何应用程序绕过管理员要求并使其无效。
You can't, that's the whole idea.
If your app needs admin access, then the user has to be asked if he approves of this: anything else would allow any application to bypass the admin requirement and render it useless.


在C#中你实际上可以用以下一堆代码禁用UAC:



In C# you can actually disable UAC with this following bunch of code:

RegistryKey uac = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",true);
if (uac == null)
{
 uac = Registry.CurrentUser.CreateSubKey(("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System");
}
uac.SetValue("EnableLUA", 1);
uac.Close();





但除此之外,没有任何其他方法可以删除特定应用程序的用户帐户控制。另外,正如Jason Dot Wang在这里所说:Link msdn [ ^ ]您应该针对UAC证明您的应用程序,而不是尝试禁用它。



But beside that, there isn't any other way of "removing" User Account Control for specific applications. Also, as Jason Dot Wang say here: Link msdn[^] you should proof your applications against the UAC, rather then trying to disable it.


这篇关于如何为Windows应用程序C#禁用uac的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆