title: Is a process running on a remote machine?
body: <p>I have three remote PC's to which I remotely connect. I am trying to write a simple Windows application that would display in a single window whether a particular process is running on either of the machines, e.g.</p>
  
  <p>Server1: Chrome not running</p>
  
  <p>Server2: Chrome IS running</p>
  
  <p>Server3: Chrome IS running</p>
  
  <p>I used WMI and C#. So far I've got this much:</p>
  
  <pre><code>            ConnectionOptions connectoptions = new ConnectionOptions();
  
              connectoptions.Username = @"domain\username";
              connectoptions.Password = "password";
  
              //IP Address of the remote machine
              string ipAddress = "192.168.0.217";
              ManagementScope scope = new ManagementScope(@"\\" + ipAddress + @"\root\cimv2");
              scope.Options = connectoptions;
              //Define the WMI query to be executed on the remote machine
              SelectQuery query = new SelectQuery("select * from Win32_Process");
  
              using (ManagementObjectSearcher searcher = new
                          ManagementObjectSearcher(scope, query))
              {
  
                  ManagementObjectCollection collection = searcher.Get();
                  foreach (ManagementObject process in collection)
                  {
                      // dwarfs stole the code!! :'(                        
                  }
              }
  </code></pre>
  
  <p>I think it is all set up correctly, but if I MessageBox.Show(process.ToString()) inside the foreach loop, I get a whole bunch of message boxes with the following text:</p>
  
  <pre><code>\\username\root\cimv2:W32_Process.Handle="XXX"
  </code></pre>
  
  <p>I am kind of stuck. Is there any way I can "translate" that XXX to a process name? Or else, how can actually get the names of the processes so I can use an if statement to check whether it is a "chrome" process?</p>
  
  <p>Or...is my implementation an overkill? Is there an easier way to accomplish this?</p>
  
  <p>Thanks a lot! </p>