在远程机器上执行 C# 代码 [英] Execute C# code on remote machine
问题描述
我有一段代码要在远程计算机上执行.我不知道该怎么做.就像我想在远程机器上执行下面给出的命令一样.
i have a piece of code which i want to execute on remote computer. I am not getting how to do that. Like if i want to execute command given below on remote machine how to do that.
Process[] processlist = Process.GetProcesses();
这只是一个例子,就像我想在带有库的远程机器上执行整个代码一样.
it is just an example, like i want to execute whole code on remote machine with libraries.
如果您要回答获取进程列表为
if you are going to answer for getting processlist as
SelectQuery selectQuery = new SelectQuery("Select * from Win32_Process");
using(ManagementObjectSearcher searcher =new ManagementObjectSearcher(manScope, selectQuery))
我已经知道了,请保存.有没有办法在连接到作用域后执行整个代码.
i already know that , please save it. is there any way to execute whole code after connecting to scope.
推荐答案
要获取远程机器上的进程列表,只需在括号中输入远程机器的名称即可..
for getting list of process on remote machine just enter name of remote machine in brackests..
Process[] processlist = Process.GetProcesses(Remotemachine);
供参考:https://msdn.microsoft.com/en-us/library/1f3ys1f9%28v=vs.110%29.aspx
这篇关于在远程机器上执行 C# 代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!