0

Well, I'm trying to run "notepad" (for example) on a remote computer, here is my code:

object[] theProcessToRun = { "notepad.exe" };
ConnectionOptions theConnection = new ConnectionOptions();
theConnection.Username = "My UserName";
theConnection.Password = "My Password";
ManagementScope theScope = new ManagementScope("\\\\" + ipAddress + "\\root\\cimv2", theConnection);
ManagementClass theClass = new ManagementClass(theScope, new ManagementPath("Win32_Process"), new ObjectGetOptions());
theClass.InvokeMethod("Create", theProcessToRun);

(I'm able to connect to the remote computer). Nothing happens - the program exits correctly, but nothing is being run on the remote.

Any ideas?

Thanks!

Idanis
  • 1,918
  • 6
  • 38
  • 69
  • Did you check Task Manager on the remote computer? Apps started via WMI do not show up on the desktop, they only show up in Task Manager. [Read here](http://msdn.microsoft.com/en-us/library/windows/desktop/aa389388(v=vs.85).aspx) "For security reasons the Win32_Process.Create method cannot be used to start an interactive process remotely." – Ove Jan 13 '13 at 10:56
  • Well, I just did, but I can't find it in the Task Manager...Regarding the security reasons you mentioned, I gave notepad as an example, when in fact I'm not trying to run an interactive process but an automatic batch script...Any clue? Thanks. – Idanis Jan 13 '13 at 11:54
  • Win32_Process.Create() requires 4 arguments, you only passed 1. Don't ignore the return value, it is the error code. – Hans Passant Jan 13 '13 at 12:25
  • I added "C$" as the "current Directory" parameter, and the following two lines in order to generate the "ProcessStartupInformation": `ManagementPath ProcessStartupMgmtpath = new ManagementPath("Win32_ProcessStartup");` and `ManagementClass processStartupClass = new ManagementClass(theScope , ProcessStartupMgmtpath, null);` still nothing...About the return value, I'm not sure how can I access it..? – Idanis Jan 13 '13 at 12:45

0 Answers0