简体   繁体   English

避免使用管理员密码UAC

[英]Avoid Admin Password UAC

We have a win form application (built on 4.0 framework client profile) which is launched from a web application with the help of a custom protocol. 我们有一个Win Form应用程序(建立在4.0框架客户端配置文件上),该应用程序是借助自定义协议从Web应用程序启动的。

For a non admin user (eg: Power user, Standard User), when the application is launched the system pops up a UAC (in the system, UAC control settings is set to "Always Notify" and it has to be the same) asking for admin password. 对于非管理员用户(例如:高级用户,标准用户),启动应用程序时,系统会弹出UAC(在系统中,UAC控制设置设置为“始终通知”,并且必须相同)询问用于管理员密码。

Note, that we are using a manifest to run the application with elevated permission for admin privilege 请注意,我们正在使用清单文件以管理员权限提升的权限运行应用程序

Any help on this to avoid the same would be appreciable. 在避免这种情况方面的任何帮助都是可取的。 Thanks in advance 提前致谢

Regards, 问候,

Karthik 卡尔提克

Simple answer: you can't. 简单的答案:你不能。 The goal of UAC is to block application from doing things that require administrative privilege without the user's approval. UAC的目标是阻止应用程序执行未经用户批准而需要管理特权的操作。 It's a security feature built into the OS so that no malicious software would put the computer in danger without the user's approval. 这是操作系统内置的一项安全功能,因此,如果没有用户的同意,则不会有恶意软件将计算机置于危险之中。

So, since it's a security feature, you can't circumvent it without the user specifically switching off the UAC on the system. 因此,由于它是一项安全功能,因此如果没有用户专门关闭系统上的UAC,就无法绕开它。

Obviously you cannot work around the security in Windows that limits what standard and power users can do. 显然,您无法解决Windows中限制标准和高级用户可以执行的操作的安全性。 It is not entirely clear from you question but if your goal is to not require elevation while running as a non-administrator then you can achieve it by following this high level procedure: 您的问题尚不完全清楚,但是如果您的目标是在以非管理员身份运行时不要求提升权限,则可以通过执行以下高级步骤来实现:

  • Remove the manifest from your executable. 从可执行文件中删除清单。 Windows will no longer require elevation before the application is executed. 在执行应用程序之前,Windows将不再需要提升权限。

  • In the initialization of your application (preferably before it becomes visible) detect if the user executing the application is administrator. 在应用程序的初始化中(最好在它可见之前),检测执行该应用程序的用户是否是管理员。

  • If the user is local administrator let the running instance of the application start a new instance of the application this time requiring elevation. 如果用户是本地管理员,则这次需要提升权限,让应用程序的运行实例启动该应用程序的新实例。 The first instance of the application then terminates when the elevated instance has started. 然后,在提升的实例启动后,应用程序的第一个实例终止。

  • If the user is not local administrator continue running the application but realize that the application is executing without administrative privileges. 如果用户不是本地管理员,请继续运行该应用程序,但应意识到该应用程序正在执行且没有管理权限。

If you do it like this an administrator will get a UAC prompt to elevate the application while non-administrators will not get any prompt (and also no administrative privileges). 如果您这样做,则管理员将收到一个UAC提示以提升应用程序,而非管理员则不会获得任何提示(并且也没有管理权限)。

You can get details about how to perform some of these tasks in an answer to a question on Stack Overflow about elevating process privilege programmatically 您可以在有关堆栈溢出的有关以编程方式提升进程特权的问题的答案中获得有关如何执行其中一些任务的详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM