I'm trying to run a command using WMI.
Posted
by MIchael Burns
on Stack Overflow
See other posts from Stack Overflow
or by MIchael Burns
Published on 2010-05-06T16:46:16Z
Indexed on
2010/05/06
16:58 UTC
Read the original article
Hit count: 234
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);
}
© Stack Overflow or respective owner