启动远程应用程序/程序以运行 [英] Initiate remote application/program to run

查看:142
本文介绍了启动远程应用程序/程序以运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,
我有一个想法,我想实现它成为现实.

假设我有两台计算机(运行XP和Windows 7或8或服务器2k8).
或者给他们起个名字:
timon:桌面
pumba:服务器

我需要做的是使一个应用程序作为服务在"pumba"上运行,而另一个应用程序(不是服务)在"timon"上运行.
当我使用某些参数启动timon_apps时,pumba_apps会产生一些效果(例如打开"notepad.exe"或在任何任务计划程序中运行任务.
意味着我想通过执行带有参数的本地应用程序来执行远程应用程序服务.
例如:

Hi everyone,
I have one idea and I want to accomplish it to be real.

Let say I have two computer (running XP and Windows 7 or 8 or server 2k8).
Or let''s give them a name:
timon : desktop
pumba : server

What I need to have is that make an application running as a service on "pumba" and another application (not a service) running on "timon".
When I launch timon_apps with some parameter pumba_apps make something (like opening "notepad.exe" or run a task any task scheduler.
Means that I want to execute the remote application service by executing a local application with a parameter.
For example :

C:\timon_apps.exe /param=notepad.exe /server=pumba


然后将"pumba_apps.exe"作为服务在pumba上运行,打开记事本应用程序.

我对我的项目清楚吗?

我并不是真的想要一个代码,而只是想知道如何实现该过程的过程以及一些实现方法的建议.

任何帮助将不胜感激.

预先感谢所有人.


and then "pumba_apps.exe" run as a service on pumba open the notepad application.

Am I clear with my project ?

I do not really want to have a code for that but only the process on how can I achieve this and some suggestions on how to make it.

Any help would be appreciated.

Thanks in advance for all.

推荐答案

首先,了解RDP服务的工作方式.您可以使用它在充当服务器的计算机上启动某些应用程序.我并不是说您应该使用 RDP .我只是说,要能够根据客户端的请求在服务器上运行应用程序,您显然需要创建Windows服务(大概是使用自动"启动选项运行),该服务是网络服务,可以接受客户的订单并代表他们启动应用程序.与自定义网络服务一样,您将需要拥有自己的应用程序级协议,该协议与RDP有点相似,但要简单得多.

如果您对如何继续使用此方法有任何疑问,我很乐意解释更多.

现在,您可以从这里开始:
http://msdn.microsoft.com/en-us/library/aa984464%28v = vs.71%29.aspx [ ^ ].

另请参见:
http://en.wikipedia.org/wiki/Remote_Desktop_Services [ http://en.wikipedia.org/wiki/Remote_Desktop_Protocol [ http://en.wikipedia.org/wiki/Application_layer [使用C#.NET的远程桌面 [ Palantir-远程桌面管理器 [ 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 [ ^ ].

最后两个MSDN页面显示了用于重定向的代码示例,并且命令行作为此Start方法的第二个参数传递:
http://msdn.microsoft.com/en-us/library/h6ak8zt5.aspx [ ^ ].

或者可以在ProcessStartInfo参数中传递:
http://msdn.microsoft.com/en-us/library/0w4h05yb.aspx [ ^ ].

如果您可以编写要在服务器端启动的应用程序,则可能会容易得多,因为您可以使用自己的应用程序级协议(根据需要设计)来设计它们,以方便地处理客户端-服务器代码.特别是,对于命令行解析,我可以推荐我的实用程序(并且在我的文章中推荐另一个替代实用程序):
基于枚举的命令行实用程序 [ http://msdn.microsoft.com/en-us/library/system. net.sockets.tcplistener.aspx [ ^ ],
http://msdn.microsoft.com/en-us/library/system. net.sockets.tcpclient.aspx [ ^ ].

另请参阅我过去有关网络服务和相关线程体系结构的一些基本思想的答案:
来自同一端口号的多个客户端 [
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.



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


这是可能适合您目的的替代解决方案:Sysinternals PsExec工具.

首先,Sysinternals是一组实用程序,对于Windows上的任何开发人员都是必备的.请参阅:
http://technet.microsoft.com/en-us/sysinternals [ http://technet.microsoft.com/en-us/sysinternals/bb897553 [ ^ ].

这是Sysinternals Mark Russinovich( http://en.wikipedia.org/wiki/Russinovich 的创建者的相关文章. [ ^ ],http://www.windowsitpro.com/author/5056226/MarkRussinovich [ http://www.windowsitpro.com/article/remote-computing/psexec [ ^ ].

我知道应该有类似的工具,但不太记得去哪里看...

祝你好运,
—SA
This is the alternative solution which might fit your purposes: Sysinternals PsExec tool.

First of all, Sysinternals is a set of utilities which a must-have for any developer on Windows. Please see:
http://technet.microsoft.com/en-us/sysinternals[^].

It would be good to download the whole suite and many utilities are very useful. This is the utility I mean:
http://technet.microsoft.com/en-us/sysinternals/bb897553[^].

This is the related article by the creator of Sysinternals Mark Russinovich (http://en.wikipedia.org/wiki/Russinovich[^], http://www.windowsitpro.com/author/5056226/MarkRussinovich[^]):

http://www.windowsitpro.com/article/remote-computing/psexec[^].

I knew the similar tool should exist, did not quite remember where to look…

Good luck,
—SA


这篇关于启动远程应用程序/程序以运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆