ManagementScope scope = new ManagementScope("\\\my_server\\root\\cimv2");
scope.Connect();
如何在my_server d:\ tools上运行批处理文件?我曾尝试过:在远程计算机上执行命令
ManagementScope scope = new ManagementScope("\\\my_server\\d\\tools");
但它似乎没有工作。
ManagementScope scope = new ManagementScope("\\\my_server\\root\\cimv2");
scope.Connect();
如何在my_server d:\ tools上运行批处理文件?我曾尝试过:在远程计算机上执行命令
ManagementScope scope = new ManagementScope("\\\my_server\\d\\tools");
但它似乎没有工作。
您需要使用Win32_Process类。
下面是其使用的一个示例:http://msdn.microsoft.com/en-us/library/ms257364(v=vs.80).aspx
实施例:
ManagementClass processClass = new ManagementClass(@"\\<remotecomputername>\root\cimv2:Win32_Process");
ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
inParams["CommandLine"] = "calc.exe";
inParams["CurrentDirectory"] = @"c:\windows\system32";
ManagementBaseObject outParams = processClass.InvokeMethod("Create", inParams, null);
决不WMI做了,但是当我需要远程运行文件我通常使用[PSEXEC](HTTP:// technet.microsoft.com/en-us/sysinternals/bb897553.aspx) –
请尝试http://www.poweradmin.com/paexec/它就像PsExec但没有错误。 – briantyler
@ TheMouthofaCow - 如何在D:\ tools上执行文件? –