简体   繁体   English

在没有 UAC 的情况下使用管理员权限从 C# 运行 PsExec

[英]Run PsExec from C# with admin right without UAC

I want to run a PSExec action, that need admin right, from a C# app launch from user space.我想从用户空间启动C#应用程序运行需要管理员权限的PSExec操作。 Of course, the complication, that's I don't want the UAC.当然,复杂的是,我不想要 UAC。

I want to run an action like this:我想运行这样的操作:

PsExec.exe -i -s powershell.exe -command "whoami *> 'out.txt'"
  • If I run example in cmd/powershell with admin right, it's work.如果我以管理员权限在 cmd/powershell 中运行示例,它就可以工作。
  • If I run example in C# exe with process with verb = "runas" , it's working如果我在 C# exe 中运行带有verb = "runas"的进程的示例,它正在工作
  • If I run example in C# exe with process with user/password/domain, it's not working如果我在 C# exe 中运行带有用户/密码/域的进程的示例,则它不起作用

I've tried a lot of other things, but I've not find a good trick.我已经尝试了很多其他的东西,但我没有找到一个好的技巧。 (powershell with credential, run a.bat or.ps1, ...) (带有凭据的powershell,运行a.bat or.ps1,...)

I'm open to every solution and/or if it's really doable.我对所有解决方案和/或是否真的可行持开放态度。

You cannot do this.你不能做这个。 Windows is a secure operating system, and you need to be an administrator to perform administrator tasks. Windows 是一个安全的操作系统,您需要成为管理员才能执行管理员任务。

Pretend for a moment that UAC doesn't exist.假装 UAC 不存在。

  • pretend that we're back on Windows XP假装我们回到了 Windows XP
  • you are a standard user你是标准用户
  • and you want to use PsExec to run something as the System account并且您想使用PsExec作为System帐户运行某些东西

You cannot.你不能。 A standard user is not allowed to compromise the security of the system like that.不允许标准用户像那样危及系统的安全性。

The only way you can do that is to run as an Administrator.可以这样做的唯一方法是以管理员身份运行。

  • On Windows XP, you would have to logoff, and get an administrator to login for you在 Windows XP 上,您必须注销,并让管理员为您登录

Windows Vista, and UAC, made it easier than having to completely switch to another user: Windows Vista 和 UAC 比完全切换到另一个用户更容易:

  • you can just enter their credentials in the UAC dialog (or press Continue)您可以在 UAC 对话框中输入他们的凭据(或按继续)

But you cannot just arbitrarily elevate yourself to an administrator - that defeats the entire purpose of having a secure operating system.但是您不能随意将自己提升为管理员——这违背了拥有安全操作系统的全部目的。

暂无
暂无

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

相关问题 通过C#启动/停止Windows服务,并以管理员身份运行,而没有UAC提示窗口 - start / stop windows service via C# with run as admin without UAC prompt window 如何创建一个 windows 应用程序,该应用程序应该在.Net C# 中以管理员权限运行,而不会一次又一次地提示 UAC? - How can I create a windows application that should run with admin rights in .Net C# without prompting UAC again and again? 从C#脚本调用中psexec的正确运行空间 - Right runspace for psexec in script call from c# Win C#:在没有UAC提示的情况下以管理员身份运行app - Win C#: Run app as administrator without UAC prompt 在不知道C#Windows应用程序窗体中的完整路径的情况下运行PsExec - Run the PsExec without knowing the full path in C# Windows application Form c#从UAC管理员级别进程降低权限启动进程 - c# starting process with lowered privileges from UAC admin level process .NET应用程序无需网络即可从网络运行 - .NET application to run from network without UAC 无法使用UAC和管理员帐户在C#中以编程方式删除文件 - Cannot delete file programmatically in C# with UAC and admin account 如何使用普通用户帐户运行C#应用程序EXE? 打开UAC时,我不想提供管理员用户名和密码 - How to run C# application EXE with normal user account? I don't want to provide Admin user name and password when UAC is on c# 在非管理员权限上运行进程 - c# run process on non-admin right
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM