110,536
社区成员
发帖
与我相关
我的任务
分享
string strCommand = @"1.bat";
strCommand = string.Format(strCommand, domainComputer.computerName);
string remoteMachine = domainComputer.computerName;//电脑名
ManagementScope manScope = new ManagementScope(String.Format(@"\\{0}\ROOT\CIMV2", remoteMachine), co);
manScope.Connect();
ObjectGetOptions objectGetOptions = new ObjectGetOptions();
ManagementPath managementPath = new ManagementPath("Win32_Process");
ManagementClass processClass = new ManagementClass(manScope, managementPath, objectGetOptions);
ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
inParams["CommandLine"] = strCommand;
inParams["CurrentDirectory"] = @"C:\Test\1\";
ManagementBaseObject outParams = processClass.InvokeMethod("Create", inParams, null);
String outMess = "Creation of the process returned: " + outParams["returnValue"] + "\n";
outMess = outMess + "Process ID: " + outParams["processId"];