title: Windows - Check if computer is locked/logged out before running tests
body: <p>I have a suite of UI tests that I run locally/remotely depending on the situation. Occasionally, the remote computers are automatically restarted whenever there is an important update to apply. This causes all the tests to time out because the remote computers they are running on are locked out and no longer have access to the GUI.</p>
  
  <p>I am wondering how I can do a quick check to see if the computer is locked or not, that way I can fail the tests quickly and log that they are offline. </p>
  
  <p>I found this solution online but it seems more catered to development and not testing. </p>
  
  <p><a href="https://bytes.com/topic/net/answers/770957-get-computer-state-locked-stand-c" rel="nofollow noreferrer">https://bytes.com/topic/net/answers/770957-get-computer-state-locked-stand-c</a></p>
  
  <p>Really just want a clean way to check if the current machine is locked or not using C# libraries and put it in a method like the one below. </p>
  
  <pre><code>public bool IsWindowsLocked(){
  
       // Check if the current machine is in a locked state
  
  }
  </code></pre>