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

本文关键字:机器 运行 进程 windows Linux 获取 | 更新日期: 2023-09-27 18:24:44

我已经尝试了一段时间,在谷歌上搜索了很多,但找不到合适的支持。在Mon上运行基于.Net的项目,并尝试获取在远程windows计算机上运行的进程id。无法继续。。。

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();

scope.Options=连接选项

我收到System.NotImplemented异常。想知道MONO是否真的支持这一点?

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

ManagementScope类中未实现任何内容:

System.Management/System.Management/ManagementScope.cs

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

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