Determine whether a computer is locked out (versus actually being in-use)?

Posted on 2010-01-07
Last Modified: 2012-05-08
Hey experts -
Is there any way to figure out if a machine has been locked out (or possibly even when screen saver is in use)? I frequently remote to workstations and use PsTools such as PsExec to deploy stuff to the machines, but the fact that I have to do this during business hours makes it a bit harder for me. I currently use psloggedon to determine if a user is logged on a machine, but it doesn't tell whether the user is actually ON the machine and currently using it or whether the user has decided to lock his machine and go out to lunch.
My current method is to:
1) use psloggedon to determine if a user is logged on, and WHEN the user logged on
2) call or email the user to request them to log off so i can patch/troubleshoot their workstation

The problem with this method is my organization has not been proactive in updating the phone roster.. so a majority of users don't even have phone numbers listed in the GAL or they have OLD numbers listed in the GAL. When i attempt to email them, most of the time they are slow to respond or don't respond at all. In addition to this, we have a good number of users who NEVER log off their machine, but lock their machine.. so my current "logon/logoff script" which records the last username/time for each computer in AD is not as accurate as it could be.

So some entries might say the user was logged on since 3 weeks ago on a particular machine even though they haven't logged on since 2 weeks ago (when they left for vacation but never logged off their machine). So what I resort to is either booting them off and hope they don't complain. What would be nice is a way to figure out when the user has locked their workstation, so I can make an executive decision and assume they left for the day and kick them off so I can do my job.
Are there any commands (i.e. pstools or sysinternals tools) or even vbscripts or batch files that can grab the status of the machine (remotely) and report it back?

And yes, yes I know that I could make some policy changes to force users to log off their machines and automatically kick them off after a certain period of inactiviy.. but that's a question for another day. That would be something that'd take some time bc I'd have to move that up the chain, and I'd rather find a quick solution now to get my work done now.  >_<!

Question by:ThinkPaper
    LVL 11

    Assisted Solution

    try to define a mapped screen saver file to a network driver, different for each computer.
    you can list all mapped screen savers under the same folder (when they are sitting on subfolder)
    and list them on "last accessed" state, or just try to list the subfolders the same way that might work.
    you can also try:

    and have they computers access a default site you defined that collects the machin's ip and creates a new file everyday.
    it's a bypass but I don't know a better way:)

    LVL 23

    Expert Comment

    This might be of interest...
    but requires the users to be Admins?
    LVL 16

    Author Comment

    i'm not interested in accessing the user's desktop, just the machine itself when the user has locked the machine. reason being - most of the machines i'm remoting into are machines I'm having trouble with one way or another.. but i wanted to find an easier way for me to determine whether its ok to boot a person off or not. (didn't want to boot them off if they happened to be.. say drafting up an important document to the CEO or something).
    LVL 16

    Accepted Solution

    Roughly based off of Giladn's, I found a good simple solution that uses the screensaver to detect inactivity..

    dim objWMIService, colItems
    strComputer = "computername"
    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2") 
    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Process",,48) 
    ssActive = false
    For Each objItem in colItems 
      if instr(1,objItem.Caption, ".scr") > 0 then
       ssActive = true 
      end if
    if ssActive = true then
      wscript.echo "Screen saver is active on " & strComputer
      wscript.echo "Screen saver not active on " & strComputer
    end if

    Open in new window

    LVL 16

    Author Comment

    - Using pslist looks like another good option you can use to determine which screensaver is active

    pslist //computer "logon.scr"  (assuming you know the exact screensaver that should be running)

    Featured Post

    Find Ransomware Secrets With All-Source Analysis

    Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

    Join & Write a Comment

    Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
    Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
    Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now