Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: Batch file to automatically log a user off after a time of inactivity

15 May 2013   #1

Batch file to automatically log a user off after a time of inactivity

Those of you who have read my posts over the past couple of weeks know what am doing on a computer belonging to an Assisted Living facility.
I have the user accounts set up plus I have removed the "Switch User and Sleep menu items from the context menu of "START.......SHUTDOWN. I have reminded the users to log off several times. I have used BRINKS tutorial to create a LOG OFF shortcut and pinned the shortcut to the task bar. Some of the users STILL fail to logoff when they are done using the computer. I am now wanting to log them out of their account after an adjustable period of inactivity Maybe you wizards can come up with a tutorial to accomplish this.
What I am thinking is a screensaver type of auto log-off. The screensaver would come on after a predetermined period of inactivity. It would have a warning msg and display a countdown. At the end of the countdown the log-off command would be initiated.
External (administrator) inputs
1. Length of inactivity.
2. Length of warning, time it is displayed.
3. Maybe text of the warning.

My System SpecsSystem Spec
15 May 2013   #2


Hi Blockie -

Since Sleep or Hibernate would save the same user session and not Log Off it's probably not what you want even though the PC would be suspended until awakened or resumed.

Doing a search I found two methods that might work for you that also provide templates for either Task Scheduler in any version, or Group Policy controls if you have Pro or Ultimate.

automatic logout after inactivity/idle using Task Scheduler

WizardSoft - AutoLogoff cleanup & end inactive Windows sessions using Group Policy.
My System SpecsSystem Spec
16 May 2013   #3


Thanks Greg,
I forgot to mention that the computer in question is running W7 Premier 64bit. That makes it not able to take advantage of Group Policy, I believe. It also saves from paying $260 for the program.
The first suggestion about using the Task Scheduler was interesting although the thread turned into a contest and I was not able to separate the wheat from the chaff, so to speak.
My System SpecsSystem Spec

16 May 2013   #4


The Task Scheduler alternative works, using Idle Timers, with one small issue: system checks the idle timer only once every 15 minutes. Whatever conditions you use, it is never exact.

For instance I use these settings but sometimes it takes almost half an hour idle time before system logs me out:
Batch file to automatically log a user off after a time of inactivity-2013-05-14_151225.png

My System SpecsSystem Spec
16 May 2013   #5


OK. Now, before I start. Is the TS choice universal? That is does it work for all the users accounts? Usually a second user does not start right away. If a second user logged into his/her account and began to do work, would he/she be logged out also? That would open another bag of worms.
My System SpecsSystem Spec
16 May 2013   #6


You need to use two triggers, On Idle and At log on.

Set first On Idle trigger:
Batch file to automatically log a user off after a time of inactivity-2013-05-14_150011.png
Do the same procedure for At log on trigger:
Batch file to automatically log a user off after a time of inactivity-2013-05-14_150213.png
It results this:
Batch file to automatically log a user off after a time of inactivity-2013-05-14_150258.png

My System SpecsSystem Spec
16 May 2013   #7


Did it and it worked, at least once. Will leave it enabled to be sure. Now for the ACTION. I would like to call a screensaver, have it run for 30 seconds displaying a warning and let it start the log off as it closes. Spent most of the afternoon looking for such a screensaver or a program to create a SS with the necessary options. Couldn't find one. Maybe one of you wizards can suggest something. Hoping !
My System SpecsSystem Spec
17 May 2013   #8


That could be tricky. The program would be launched when the system is already starting the log off process.
My System SpecsSystem Spec
17 May 2013   #9


I think you misunderstand what I am thinking. I would like the ACTION tab of the task to operate in this fashion.
1. Start a screensaver
a. This SS would only be about 30 second long
b. It would display a warning that the system is about to log off, with a timer to countdown to zero, if possible.
2. At time zero, see 1b above, or if countdown timer is not available, initiate the program to log off after the SS closes, see 1a above.
My System SpecsSystem Spec
17 May 2013   #10


No, I understood you. It's just that I have been testing an playing this idle timer so much I doubt it works as you planned. Tasks with idle timer are IMO the most difficult to get working as you'd like to.
My System SpecsSystem Spec

 Batch file to automatically log a user off after a time of inactivity

Thread Tools

Similar help and support threads
Thread Forum
Need batch file to disable the date and time option
Hello, I need batch file or registry to disable the date and time option
General Discussion
Batch File to set user's windows login pic
Alright, I'm doing a little bit of research to help automate some customizations that I'm doing for my client's computers. I've got most of what I need done. But what I am trying to do now is set the user's current profile picture to one that is already there. The picture itself isn't going to...
Batch file to create a folder with name of the time.
I'm trying to write a batch file that when run creates a folder named "Backup" followed by the time it was created, and then copies files to that folder. When I run md "C:\Users\MasterControlProgram\Documents\MC Server With Backup\Backups\Backup %DATE%\" xcopy /e /v /y...
Backup and Restore
Help with Batch file, if statement in a specific time.
hi, I am working on a batch file, such as If this is not possible, then just simply, Thanks!
General Discussion
Batch file to run MMC as a different domain user?
I'm stumped. I have a batch file that I used on XP to run an MMC that I created for common management tasks. In the MMC I have the ability to run regedit as a root forest domain privileged user (for remote system registry editing), password resets (using AD) remote computer management, and...
General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 19:46.
Twitter Facebook Google+ Seven Forums iOS App Seven Forums Android App