如何在不添加清单文件的情况下以管理员身份运行基于c#代码的应用程序? [英] How do i run my c# code based application as administrator without adding manifest file?

查看:117
本文介绍了如何在不添加清单文件的情况下以管理员身份运行基于c#代码的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是我电脑中的用户,然后我创建了一个与打印机相关的代码,为此我添加了清单文件并将requestedExecutionLevel更改为

I'm as user in my pc, then I created a code that inetracts with printer, to do this I added manifest file and changed the requestedExecutionLevel to

<requestedexecutionlevel level="requireAdministrator" uiaccess="false" />



当我运行它时,它需要管理员登录和密码。一旦我知道管理员密码,那么我将添加使用它,以便应用程序必须以管理员身份运行而不需要再次使用管理员密码,它应该直接工作。是否可以将管理员的登录名和密码添加到清单文件或源代码中?



我尝试过:



我添加了清单文件并将requestedExecutionLevel更改为


when I run it, it requires admin login and password. Once I know admin password then I'm going to add use it so that application must run as administrator without requiring admin password again, it should work directly. Is it possible to add admin's login and password into manifest file or source code?

What I have tried:

I added manifest file and changed the requestedExecutionLevel to

<requestedexecutionlevel level="requireAdministrator" uiaccess="false" />



当我运行它,它需要管理员登录和密码。一旦我知道管理员密码,那么我将添加使用它,以便应用程序必须以管理员身份运行而不需要再次使用管理员密码,它应该直接工作。是否可以将管理员的登录名和密码添加到清单文件或源代码中?


when I run it, it requires admin login and password. Once I know admin password then I'm going to add use it so that application must run as administrator without requiring admin password again, it should work directly. Is it possible to add admin's login and password into manifest file or source code?

推荐答案

你不能这样做。首先,当管理员密码更改时,您的代码将会中断。其次,您真的要将管理员级别的密码放入PLAIN TEXT的文件中吗?那是什么样的安全?!?!?!



您可以使用requestedexecutionlevel将清单文件放在那里,然后放上凭证对话框,或者你不要运行你的申请。



安全是有原因的。这是为了防止您在不知道OR的情况下盲目地使用管理员凭据,因为代码始终以启动它的用户身份运行,让其他代码在您不知情的情况下使用您的管理安全令牌。
You can't do that. First, when the administrator password changes, your code is going to break. Second, are you REALLY going to put an admin level password into a file in PLAIN TEXT? What kind of security is that?!?!?!

You either put the manifest file in there with the requestedexecutionlevel and put up with the credential dialog or you don't run your application.

The security is there for a reason. It's to prevent you from blindly using your admin credentials without knowing OR, since code always runs as the user that launched it, having other code use your admin security token without you knowing it.


这篇关于如何在不添加清单文件的情况下以管理员身份运行基于c#代码的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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