views:

30

answers:

3

Is it possible for one C# (desktop) application to start and stop applications on another machine?

I don't mean in a malicious sense, or even over the internet. I have two computers in a room and I need an app on one to start (and then stop) and app on the other.

One half-formed route in my mind was to use an auxiliary program on the target computer, so I suppose I ought to point out that I am completely able to make any necessary changes to either machine.

A: 

psexec.exe from sysinternals or Use Powershell 2.0 and WMI

Mitch Wheat
+2  A: 

If you can do changes there are so many possibilities!

  • WMI : Never tried that out but given sufficient rights you should be able to start processes, or at least services on a remote machine
  • .NET remoting: Somewhat old, but easy to implement
  • WCF
  • HttpListener
  • Private Message Queues (that's what I did once)
  • ?

Most of the alternatives involve writing a small service that listens on the communication technique of your choice and then starts a process or does something else.

flq
+2  A: 

An example using WMI is up on Code Project:

Create a Remote Process using WMI in C#

But probably in your case a simple PsExec.exe call might be enough, e.g.

Process.Start("psexec.exe", "\\remotehost -u user -p password calc.exe");
0xA3