Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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!

Mike

share|improve this question
add comment

2 Answers

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: http://msdn.microsoft.com/en-us/library/ms646302(VS.85).aspx

share|improve this answer
add comment

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.

JR

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
add comment

Your Answer

 
discard

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.