C# 在远程计算机c上启动进程#
我正在使用下面的代码在远程机器上启动一个进程。它确实会启动进程,但它是在Admin用户(而不是当前登录的用户)下运行的。我需要当前用户能够与程序交互。如果我在代码中使用他们的凭据而不是admin,那么我将获得拒绝访问的权限。如何指定在用户“JohnDoe”下运行?我知道PSSuite是一个选项,但如果可能的话,我宁愿使用ManagementScope类C# 在远程计算机c上启动进程#,c#,windows,security,wmi,impersonation,C#,Windows,Security,Wmi,Impersonation,我正在使用下面的代码在远程机器上启动一个进程。它确实会启动进程,但它是在Admin用户(而不是当前登录的用户)下运行的。我需要当前用户能够与程序交互。如果我在代码中使用他们的凭据而不是admin,那么我将获得拒绝访问的权限。如何指定在用户“JohnDoe”下运行?我知道PSSuite是一个选项,但如果可能的话,我宁愿使用ManagementScope类 class Program { static void Main(string[] args) { try
class Program
{
static void Main(string[] args)
{
try
{
object[] theProcessToRun = { "notepad.exe" };
ConnectionOptions theConnection = new ConnectionOptions();
theConnection.Username = @"MyDomain\Admin";
theConnection.Password = "mypassword";
ManagementScope theScope = new ManagementScope("\\\\" + "BMBM14" + "\\root\\cimv2", theConnection);
ManagementClass theClass = new ManagementClass(theScope, new ManagementPath("Win32_Process"), new ObjectGetOptions());
theClass.InvokeMethod("Create", theProcessToRun);
Console.WriteLine("Success");
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
Console.ReadLine();
}
Console.ReadLine();
}
}
尝试检查远程计算机中用户的WMI安全设置。另外,您是否知道不能使用
Win32\u进程
类执行交互进程?我不知道。有什么建议吗?我需要在远程计算机上启动尚未运行的应用程序。如果用户帐户没有远程登录的权限(默认情况下,此权限已关闭IIRC),请尝试此操作,然后您肯定会被拒绝访问。RRUZ。把你的答案贴出来,这样我就可以把它标记为正确答案。谢谢