Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

Start an application in remote machine using WMI(C#)

$
0
0

I am trying to start an application in another machine which is in the same network using following code:

            var processToRun = new[] { "notepad.exe" };
            var connection = new ConnectionOptions();
            //connection.Impersonation =
            //System.Management.ImpersonationLevel.Impersonate;
            connection.Username = "user";
            connection.Password = "pass";
            var wmiScope = new ManagementScope(String.Format("\\\\{0}\\root\\cimv2", "192.168.0.1"), connection);
            wmiScope.Connect();
            var wmiProcess = new ManagementClass(wmiScope, new ManagementPath("Win32_Process"), new ObjectGetOptions());
            wmiProcess.InvokeMethod("Create", processToRun);

This code is running fine without any error, but it is still not starting the notepad in the another machine. 

I also checked in the task manager process list, its not there.

So i am not getting where i am doing mistake. Also Please let me know of there is any other approach.

Thanks in advance :)


chandra



Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>