我正在通过WMIC执行远程CMD命令行,这需要几秒钟的时间才能运行。在继续前,我正在做Thread.Sleep(4000)...那里必须有更好的方法!是否有一个变量或方法可用于确定我发出的命令是否完成/状态字节?WMIC MangementClass RemoteCommand - 确定何时完成? STDOUT?
谢谢!使用
林下面的代码来发出命令:
ManagementClass processTask = new ManagementClass(@"\\" + this.wmiConnection.machineName + @"\root\CIMV2", "Win32_Process", null);
ManagementBaseObject methodParams = processTask.GetMethodParameters("Create");
methodParams["CommandLine"] = command;
methodParams["CurrentDirectory"] = @"C:\";
只需要弄清楚如何确定当命令完成:)。谢谢!