C# を使用して、リモート コンピューターのコマンド プロンプトでコマンドを実行したいと考えています。このリンクごとリモートコンピューターでコマンドを実行する方法? 、次のコードを使用してこれを実行しようとしています:
public static void RunRemoteCommand(string command, string RemoteMachineName)
{
ManagementScope WMIscope = new ManagementScope(
String.Format("\\\\{0}\\root\\cimv2", RemoteMachineName));
WMIscope.Connect();
ManagementClass WMIprocess = new ManagementClass(
WMIscope, new ManagementPath("Win32_Process"), new ObjectGetOptions());
object[] process = { command };
object result = WMIprocess.InvokeMethod("Create", process);
Log.Comment("Creation of process returned: " + result);
}
これは終了コード 0 を返し、エラーはスローされませんが、何も実行されません。助けてください。