How to execute process on remote machine, in C#

How can I start a process on a remote computer in c#, say computer name = "someComputer", using System.Diagnostics.Process class?

I created a small console app on that remote computer that just writes "Hello world" to a txt file, and I would like to call it remotely.

Console app path: c:\MyAppFolder\MyApp.exe

Currently I have this:

ProcessStartInfo startInfo = new ProcessStartInfo(string.Format(@"\\{0}\{1}", someComputer, somePath);

            startInfo.UserName = "MyUserName";
            SecureString sec = new SecureString();
            string pwd = "MyPassword";
            foreach (char item in pwd)
            startInfo.Password = sec;
            startInfo.UseShellExecute = false;


I keep getting "Network path was not found".


Can can use PsExec from


object theProcessToRun() = { "YourFileHere" };

ManagementClass theClass = new ManagementClass(@"\\server\root\cimv2:Win32_Process");

theClass.InvokeMethod("Create", theProcessToRun);

Use one of the following:

Or if you feel like it, inject your own service or COM component. That would be very close to what PsExec does.

Of all these methods, I prefer task scheduler. The cleanest API of them all, I think. Connect to the remote task scheduler, create a new task for the executable, run it. Note: the executable name should be local to that machine. Not \servername\path\file.exe, but c:\path\file.exe. Delete the task if you feel like it.

All those methods require that you have administrative access to the target machine.

ProcessStartInfo is not capable of launching remote processes.

According to MSDN, a Process object only allows access to remote processes not the ability to start or stop remote processes. So to answer your question with respect to using this class, you can't.

I don't believe you can start a process through a UNC path directly; that is, if System.Process uses the windows comspec to launch the application... how about you test this theory by mapping a drive to "\someComputer\somePath", then changing your creation of the ProcessStartInfo to that? If it works that way, then you may want to consider temporarily mapping a drive programmatically, launch your app, then remove the mapping (much like pushd/popd works from a command window).

Need Your Help

Pivot SQL query - Show Date in column

sql sql-server-2005

my current query return the below result

Kerberos authorization as different user

c oracle kerberos

In my programm programmed on c, i want to connect to Oracle using differen user names without using password. That's mean, that user already connected to desktop in Active Directory and already ent...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.