title: C#-friendly alternatives to WMI for iterating remote processes by Owner?
body: <p>We have some code that works, but too slowly.  We use a System.Management.ManagementObjectSearcher to run an ObjectQuery for "Select * from Win32_Process).  We then iterate the returned list, call "GetOwner" (via InvokeMethod) to see if the process is by the user we are searching for, and then call "Terminate" (also via InvokeMethod).</p>
  
  <p>With some additional exception handling to account for processes that terminate while they are being iterated, this works, but on the machines with many thousands of processes we need to run this on, it takes fully an hour to iterate all the processes.</p>
  
  <p>Is there an alternative that doesn't involve having a footprint on the target server?  The remote part is key to what we're doing.  If we have to go local, we have the option of the win32 api, but I imagine WMI would be fast enough if run locally.</p>