简体   繁体   English

从 Linux c# 获取在远程 Windows 机器上运行的进程

[英]Get a process running on remote windows machine from Linux c#

I've been trying since a while and googled a lot but couldn't find proper support.我已经尝试了一段时间并在谷歌上搜索了很多,但找不到适当的支持。 Running .Net based project on Mon and trying to fetch Process id running on a remote windows machine.在 Mon 上运行基于 .Net 的项目并尝试获取在远程 Windows 机器上运行的进程 ID。 And cannot go ahead...并且不能继续...

ConnectionOptions connectoptions = new ConnectionOptions();     
string ipAddress = "XX.XX.X.XXX";

ManagementScope scope = new ManagementScope(@"\\" + ipAddress + @"\root\cimv2", connectoptions);
scope.Options = connectoptions; 
var query = new SelectQuery("select * from Win32_process where name = '" +    ProcessName + "'");
List<int> EPids = new List<int>();

using (ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query))
{
    foreach (ManagementObject EProcess in searcher.Get()) 
    {
       var pId = Convert.ToInt32(EngineProcess["ProcessId"]);                                
                EnginePids.Add(pId);
                Console.WriteLine(pId);                                                  
    }
}           
return EPids.ToArray();

At

scope.Options = connectoptions scope.Options = 连接选项

I recive a System.NotImplemented exception.我收到一个 System.NotImplemented 异常。 Wondering if MONO actually supports this?想知道 MONO 是否真的支持这个?

Nothing is implemented in the ManagementScope Class: ManagementScope类中没有实现任何内容:

System.Management/System.Management/ManagementScope.cs

public ConnectionOptions Options {
   [MonoTODO]
   get {
      throw new NotImplementedException ();
   }
   [MonoTODO]
   set {
      throw new NotImplementedException ();
   }
}

Ref: https://github.com/mono/mono/blob/b7a308f660de8174b64697a422abfc7315d07b8c/mcs/class/System.Management/System.Management/ManagementScope.cs参考: https : //github.com/mono/mono/blob/b7a308f660de8174b64697a422abfc7315d07b8c/mcs/class/System.Management/System.Management/ManagementScope.cs

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

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