[英]RunAs running under LocalSystem C#
We are trying to execute a process, let's say "cmd.exe" under another username credentials.我们正在尝试执行一个进程,比如说另一个用户名凭据下的“cmd.exe”。 The application is running as a WCF service under LocalSystem account.
该应用程序在 LocalSystem 帐户下作为 WCF 服务运行。 We have tried several methods(Process.start, CreateProcessWithLogOn, etc) and all seem to fail with "Access denied".
我们尝试了几种方法(Process.start、CreateProcessWithLogOn 等),但似乎都以“拒绝访问”而失败。
Does anyone know how to do it?有谁知道该怎么做? Is there any way out there to do it?
有没有办法做到这一点?
var myProcess = new ProcessStartInfo(path)
{
UserName = username,
Password = MakeSecureString(password),
UseShellExecute = false, LoadUserProfile = true
};
Tried setting UseShellExecute to false for the ProcessStartInfo ?尝试将ProcessStartInfo的UseShellExecute设置为 false 吗? Or setting LoadUserProfile to false.
或者将 LoadUserProfile 设置为 false。 Also your secure string maybe built incorrectly, did you try to use plain text password (temporarily, just to isolate the problem)?
此外,您的安全字符串可能构建不正确,您是否尝试使用纯文本密码(暂时,只是为了隔离问题)? Does process start if you just use RunAs from command line?
如果您只是从命令行使用 RunAs,进程是否会启动?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.