如何以编程方式创建任务以自动以管理员身份运行应用 [英] How to create a task programatically to run app as admin automatically

查看:103
本文介绍了如何以编程方式创建任务以自动以管理员身份运行应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最终目标是在启动时以管理员身份运行指定的exe,而无需确认.可以通过Task Planner手动完成,但是在编程上可能可行,我想知道如何做.谢谢.

Final goal is to run specified exe as admin on startup, WITHOUT confirmation. It can be done manually via Task Planner, but its possible programatically, I want know how. Thanks.

推荐答案



在这里看看:
http://msdn.microsoft.com/en-us/library/ms742884.aspx [ ^ ]
Hi,

Have a look here:
http://msdn.microsoft.com/en-us/library/ms742884.aspx[^]


如果您以不需要不确认的方式进行操作,则它将完全破坏UAC提供的保护的目的.这不是很明显吗?

最好使您的应用程序自动请求确认.在这种情况下,用户只会点击是"或否".您可以将清单添加到应用程序中,并通过以下方式进行配置:
http://msdn.microsoft.com/en-us/library/bb756929.aspx [ ^ ],
http://www.aneef.net/2009 /06/29/request-uac-elevation-for-net-application-managed-code/ [ http://4sysops.com/archives/vista%E2%80%99s-uac-8-ways-how-to-elevate-an-application-to-run-it-with-administrator-rights/ [ http://www.sevenforums.com/tutorials/11841-run-administrator.html [ ^ ].

原则上,如果关闭UAC确认,则可以实现所需的功能. 我不建议您这样做.请参阅:
http://www.petri.co.il/disable-uac-in-windows- 7.htm [ ^ ].

同样,最好的食谱是:不要这样做.

—SA
If you did it the way requiring no confirmation, it would completely defeat the purpose of the protection provided by UAC. Isn''t that obvious?

Better make your application request the confirmation automatically. In this case, the user would only hit "Yes" or "No". You can add the manifest to the application and configure it this way:
http://msdn.microsoft.com/en-us/library/bb756929.aspx[^],
http://www.aneef.net/2009/06/29/request-uac-elevation-for-net-application-managed-code/[^].

See also these articles:
http://4sysops.com/archives/vista%E2%80%99s-uac-8-ways-how-to-elevate-an-application-to-run-it-with-administrator-rights/[^] (here, the motivation of options is discussed please see),
http://www.sevenforums.com/tutorials/11841-run-administrator.html[^].

In principle, you can achieve what you want if you switch off the UAC confirmation. I would not recommend doing that. Please see:
http://www.petri.co.il/disable-uac-in-windows-7.htm[^].

Again, the best recipe is: don''t do it.

—SA


这篇关于如何以编程方式创建任务以自动以管理员身份运行应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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