简体   繁体   中英

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. 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

I recive a System.NotImplemented exception. Wondering if MONO actually supports this?

Nothing is implemented in the ManagementScope Class:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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