如何避免用户帐户控制或在Win7中运行Windows应用程序始终处于管理模式管理模式、应用程序、帐户、用户

2023-09-06 14:05:18 作者:微微一笑很倾城

在WinForms应用程序时,我的应用程序启动,然后在用户帐户控制DialogBox的来(仅在Windows7)。

In WinForms application when my application is started then the User Account Control dialogbox comes(Only in Windows7).

任何人都可以给我建议,我可以如何编程避免这种情况 - 那是我的应用程序应该在管理模式始终启动或有任何选项来阻止这种DialogBox的来自哪里

Can anyone suggest me how programatically I can avoid this - That is my application should start always in admin mode or is there any option to stop this dialogbox from coming?

我发展在C#中,VS2008。

I am developing in C#,VS2008.

推荐答案

您无法自动启动具有更高权限的应用程序不接受的提示或告知Windows来总是以更高的特权应用程序。如果能够以编程方式改变这种行为会破坏UAC的全部目的。 UAC会自动出现,如果它的积极和应用程序做一些事情,需要比当前用户更高的权限。作为一个管理员用户不给你做的一切,而不先确认的权利,这实际上只有提升你的权限,如果UAC处于活动状态。

You cannot automatically start an application with higher privileges without accepting the prompt or telling Windows to always start that application with higher privileges. Being able to programatically change this behaviour would defeat the whole purpose of UAC. UAC comes up automatically if it's active and an application does something that requires higher privileges than the current user. Being an administrator user does not give you the rights to do everything without confirmation first, which actually only then elevates your privileges if UAC is active.

你应该做的是追查究竟是什么触发UAC的应用程序,并删除或修改它,使应用程序并不需要更高的权限才能成功完成该任务。你也可以检查,如果您的应用程序的清单要求更高的权限,在清单检查requestedExecutionLevel。如果你其实需要更高的权限,你唯一的办法是要么告诉用户关闭UAC仍然并不意味着正常的用户能够运行应用程序。或启动应用程序时,应时刻接受提示。

What you should do is track down what actually triggers UAC in your application and remove that or modify it so that the application does not need higher privileges to successfully complete that task. You could also check if the manifest of your application requests higher privileges, check for requestedExecutionLevel in the manifest. In case you actually do need higher privileges your only way is to either tell the users to turn off UAC which still does not mean a "normal" user is able to run your application. Or to always accept the prompt when starting your application.