簡體   English   中英

從 Linux c# 獲取在遠程 Windows 機器上運行的進程

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

我已經嘗試了一段時間並在谷歌上搜索了很多,但找不到適當的支持。 在 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 是否真的支持這個?

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM