简体   繁体   English

WMI远程进程无法启动,可以在本地启动

[英]WMI remote process fails to start, starts locally fine

The following code works when "SelectedMachine" is the localhost where the C# exe is being launched from. 当“ SelectedMachine”是启动C#exe的本地主机时,以下代码有效。 When "SelectedMachine" is a remote machine, the process simply doesn't launch. 如果“ SelectedMachine”是远程计算机,则该过程根本不会启动。 No exceptions, no errors, acts as if it's successful, however, the process never starts. 没有例外,没有错误,就好像成功一样,但是,该过程永远不会开始。 Any ideas? 有任何想法吗?

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 );    

Edit: When I go through wbemtest, same behavior occurs. 编辑:当我通过wbemtest时,会发生相同的行为。 When the Namespace is root\\cimv2 (local), the process executes, when it is \\RemoteMachineName\\root\\cimv2, it claims success but never starts on the remote machine. 当命名空间为root \\ cimv2(本地)时,将执行该进程,当命名空间为\\ RemoteMachineName \\ root \\ cimv2时,它将声明成功,但从不在远程计算机上启动。 Not sure what I'm missing here. 不知道我在这里想念的是什么。

This behavior is described in the Win32_Process.Create method documentation. Win32_Process.Create方法文档中对此行为进行了描述。

For security reasons the Win32_Process.Create method cannot be used to start an interactive process remotely. 出于安全原因,Win32_Process.Create方法不能用于远程启动交互过程。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM