We help IT Professionals succeed at work.

We've partnered with Certified Experts, Carl Webster and Richard Faulkner, to bring you two Citrix podcasts. Learn about 2020 trends and get answers to your biggest Citrix questions!Listen Now


Looking for "after idle for x minutes, logoff" solution

piattnd asked
Medium Priority
Last Modified: 2012-05-06

I need to review the possibilities of scripting a solution to log off a user after "X" idle time.  I've researched some possibilities, however I haven't come up with anything yet.

From the sounds of it, WMI does not have a method to check the idle time on a windows session.

One of the things I was thinking about trying is to read the position of the mouse and storing the position in a variable.  If the position is the same, then the computer is idle; however, the only way I can think of to check the mouse position is to set an app as focus and check the mouse positioning there.

Does anyone have any possible solutions for this?  I'd prefer to stick to scripting methods and stay away from third party software, but any suggestions are welcome.
Watch Question

tigermattSite Reliability Engineer
Most Valuable Expert 2011


I'd use the WinExit screensaver which you can find information on at http://windowsxp.mvps.org/winexit.htm.

Assuming we're talking about an Active Directory network, once the screensaver tool is installed on each computer on your network, you'd be able to force all PCs to use it through Group Policy - so users cannot change the setting.



I saw this in another post, but there are a few other items we have to try and close "properly" to prevent any issues, which is why I'm hoping for a scriptable solution, so I can close any programs needed or send any commands to the machine before logging the user off.  I've kept this one in mind thouhg.

Anything else?
Site Reliability Engineer
Most Valuable Expert 2011

Could you use a Scheduled Task which runs a script? There is the option in the Advanced Settings of the schedule on a Scheduled Task to have it run only when the computer is idle for a set period of time. You could easily create a task which runs on idle for X minutes, with the task launching your script to close down the appropriate applications and then log the user off.

The command for logging a user off (in a Windows Shell) would be shutdown.exe -l - and you'd obviously do this last, after you'd run commands to shut other programs.

A less desirable approach - but one that will definitely work.


Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts


Hmm, I'll have to give that one a shot,  but as you said, not exactly desireable.  I'll check out that possibility as well.

If you want to run a script to close all application safely, the best way to know when the workstation is idle for X minutes, is still to make you script as a screensaver.
If you can't make a screensaver that do the job, you can also set a defined screensaver (like logon.scr) and look when it's running using vbs :


when's it's running, it's time to start your script.


That's a good thought too.  I'll take a look at both of these items on Monday.


Thank you both for your help.  This project has slipped to the back burner for now, but I'm closing this question.  Thanks for the answers!
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.