I'm trying to run a command using WMI.
- by MIchael Burns
This is my code: a button is clicked and the text in a textbox is taken for the remotePC. I can run it locally but when I try to run it remotely it will not work, I think it has something to do with using WMI to run a shared file?
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);
}