First, look how RDP service works. You can use it to launch some applications on the machine acting as a server. I'm not saying that you should use
RDP. I'm just saying that to be able to run applications on the server on request of client, you apparently need to create a Windows Service (presumably, running with the "Auto" start-up option), which is a network service and which can take orders from the clients and launch applications on their behalf. As always with the custom network services, you will need to have your own
application-level protocol, somewhat similar to RDP, only much simpler.
If you have any questions on how to proceed with this approach, I gladly explain more.
For now, you can start here:
http://msdn.microsoft.com/en-us/library/aa984464%28v=vs.71%29.aspx[
^].
See also:
http://en.wikipedia.org/wiki/Remote_Desktop_Services[
^],
http://en.wikipedia.org/wiki/Remote_Desktop_Protocol[
^],
http://en.wikipedia.org/wiki/Application_layer[
^].
However, running the UI applications like Notepad make no sense at all. You will start it on the server side, so what? Don't think it can be shown on the client screen or something like that. If this is what you need, simply use RDP. There are a couple of good CodeProject articles where the authors present their own RDP clients. Using them, you will see how can you use RDP protocol in your own client-side application:
Remote Desktop using C#.NET[
^],
Palantir - Remote Desktop Manager[
^].
The second one, Palantir, is my favorite; it once helped me in the situation where the Microsoft client was failing to do the job.
[EDIT: in response to the comment to this answer:]
Please see my comment below, about piping the input and output of the application to be executed on the server side. Instead of relying on some files (which would be just additional channel of data exchange which you would need to devise, care about synchronization, etc. — too boring stuff), you can use some applications which could work in the console-mode on the server.
To pass data to such application, you have two mechanism: first, you can pass a command line string which your service should pass to the application; second: if you have an application which can work with interactive console input from the user, you can pipe such input by redirecting the
StandardInput
stream.
To get output from the console application, you could redirect the streams
StandardOutput
and/or
StandardError
.
Please see the class
System.Diagnostics.Process
and code samples related to command line and redirection:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standarderror.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardinput.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardoutput.aspx[
^].
Two last MSDN page show the code sample for re-direction, and the command line is passed as a second parameter of this
Start
method:
http://msdn.microsoft.com/en-us/library/h6ak8zt5.aspx[
^].
Or it can be passed in the
ProcessStartInfo
parameter:
http://msdn.microsoft.com/en-us/library/0w4h05yb.aspx[
^].
If you can write the applications to be started on the server side, it can be much easier because you can design them to be convenient for working through your client-server code using your own application-level protocol designed according to your needs. In particular, for command line parsing I could recommend my utility (and another, alternative utility is recommended in my article):
Enumeration-based Command Line Utility[
^].
For networking, there are a number of alternatives on different levels, from sockets to self-hosted WCF. In your case, I would rather recommend using the classes
System.Net.Sockets.TcpListener
and
System.Net.Sockets.TcpClient
:
http://msdn.microsoft.com/en-us/library/system.net.sockets.tcplistener.aspx[
^],
http://msdn.microsoft.com/en-us/library/system.net.sockets.tcpclient.aspx[
^].
Please also see my past answer on some basic ideas about networking service and related threading architecture:
Multple clients from same port Number[
^].
Your follow-up questions are quite welcome.
—SA