Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to be able to query whether the currently logged in user is idle at their PC - i.e. their PC believes they are 'inactive'... The problem is there are so many ways this could be done. Is there a universal: "THIS COMPUTER IS IDLE/INACTIVE" - I'm thinking about using whatever measure the power subsystem uses...

My thought is to use WMI/Powershell but I could also use a .NET call in C# - I'd just rather not!

Sorry to be a bit vague on this and I'm more than happy for anybody to edit my question into something more meaningful!


share|improve this question

If you're willing to hack it and look for a screensaver to detmine inactivity you might as well use powershell to see if the session is inactive (i.e. the computer is locked):

QUERY SESSION /server:MachineName UserName

it uses the terminal services interface to see if a user is attached to a session. This works because in modern versions of windows all local users are treated as being console sessions of the computer. The two status of interest are:

  • Active: Logged in and using
  • Disconnected: logged in but the screen is locked or user is detached

As it's based on the old qwinsta functionality rather than being fully OO you'll need to do some string manipulation if you want a boolean out of it (i.e. -contains "Active").

For an accurate figure (and what screensavers themselves are generally driven by) look at the LastInputInfo() win32 API call but you need to run it in the user's context which is usually a deal breaker if you need remote monitoring. Here's the MSDN article though:

share|improve this answer

No is the simple answer.

I have in the past used WMI to list the running processes and looked for the screen saver. If the screen saver is running they are inactive in one sense, though you still can't tell if they've left an app running. You can check things like CPU and/or disk actvity, but it's hard to get a firm answer from these.


share|improve this answer
John, I thought that was probably the answer! Hopefully, somebody else has found a solution that is workable. – Mike McClelland Jul 6 '09 at 8:31

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.