这是我的代码:单击一个按钮并为remotePC采用文本框中的文本。我可以在本地运行它,但是当我尝试远程运行它时,它不起作用,我认为它与使用WMI运行共享文件有关?我正在尝试使用WMI运行命令
public void IPXFER(string RemotePC)
{
object[] theProcessToRun = { @"\\network-share\ipxfer\ipxfer.exe -s corp-trend -p 1234 -m 1 -c 12345" };
ConnectionOptions theConnection = new ConnectionOptions();
theConnection.Impersonation = ImpersonationLevel.Impersonate;
theConnection.EnablePrivileges = true;
ManagementScope theScope = new ManagementScope("\\\\" + RemotePC + "\\root\\cimv2", theConnection);
ManagementClass theClass = new ManagementClass(theScope, new ManagementPath("Win32_Process"), new ObjectGetOptions());
theClass.InvokeMethod("Create", theProcessToRun);
}
我添加了file.copy将共享文件复制到remotepc,这很好,但是当我尝试执行批处理文件时,它不起作用。我唯一能想到的是,当wmi在不同的会话中运行这个批处理文件时? – 2010-05-06 18:09:41