title: Fetch Users With Active Status on WIndows System
body: <p>How can I fetch the list of users who are active and disconnected on the Windows Server System (similar to the list shown in Users' tab of Task Manager) using C#?</p>
  
  <p>So far I could only fetch the list of all users on the system like as follows:</p>
  
  <pre><code>using System.Management;
  
  SelectQuery query = new SelectQuery("Win32_UserAccount");
  ManagementObjectSearcher searcher = new ManagementObjectSearcher(query);
  foreach (ManagementObject envVar in searcher.Get())
  {
       Console.WriteLine("Username : {0}", envVar["Name"]);
  }
  </code></pre>
  
  <p>But I need the list of users who are currently active and disconnected. </p>