tags:

views:

69

answers:

2

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);
}
A: 

What error are you getting? See this link if it is one among the mentioned errors. Also take a look at this link to see if you are missing anything.

danish
I get no error, in fact if I change theProcessToRun to notepad.exe it will run fine, I can see it in the processes with my username that was used to run it. I think it has something to do with it being on a network-share with WMI.
Michael Burns
A: 

I ended up using file.copy and then executing the exe with the switches with WMI, that fixed the issue.

Michael Burns