简体   繁体   English

如何在其他计算机上启动/停止应用程序?

[英]How can I start/stop applications on a different computer?

Is it possible for one C# (desktop) application to start and stop applications on another machine? 一个C#(桌面)应用程序是否可以在另一台计算机上启动和停止应用程序?

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. 我心中的一条半成型路线是在目标计算机上使用辅助程序,因此我想指出的是,我完全有能力对任一台计算机进行必要的更改。

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 WMI:从未尝试过,但是拥有足够的权限,您应该可以启动进程,或者至少在远程计算机上提供服务
  • .NET remoting: Somewhat old, but easy to implement .NET远程处理:较旧,但易于实现
  • WCF WCF
  • HttpListener 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. 大多数替代方案涉及编写一个小型服务,该服务侦听您选择的通信技术,然后启动一个进程或执行其他操作。

An example using WMI is up on Code Project: 代码项目中提供了一个使用WMI的示例:

Create a Remote Process using WMI in C# 在C#中使用WMI创建远程进程

But probably in your case a simple PsExec.exe call might be enough, eg 但是可能在您的情况下,简单的PsExec.exe调用就足够了,例如

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

来自sysinternals的psexec.exe或使用Powershell 2.0和WMI

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM