当“SelectedMachine”是从中启动C#exe的本地主机时,以下代码有效。当“SelectedMachine”是远程计算机时,该过程根本无法启动。没有例外,没有错误,就好像它是成功的,然而,这个过程永远不会开始。有任何想法吗?
object[] processToRun = { "notepad.exe" };
ConnectionOptions connOptions = new ConnectionOptions();
connOptions.Impersonation = ImpersonationLevel.Impersonate;
connOptions.Authentication = AuthenticationLevel.PacketPrivacy;
connOptions.EnablePrivileges = true;
ManagementScope manScope = new ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", SelectedMachine), connOptions);
manScope.Connect();
ObjectGetOptions objectGetOptions = new ObjectGetOptions();
ManagementPath managementPath = new ManagementPath("Win32_Process");
ManagementClass processClass = new ManagementClass(manScope, managementPath, objectGetOptions);
processClass.InvokeMethod("Create", processToRun );
编辑:当我通过wbemtest时,会发生同样的行为。当命名空间是root \ cimv2(本地)时,进程执行,当它是\ RemoteMachineName \ root \ cimv2时,它声明成功但永远不会在远程计算机上启动。不知道我在这里缺少什么。