Subscribe

Get the Network Administrators tool pack

Subscribe to our newsletter and get 11 free network administrator tools, plus a 30 page user guide so you can get the most out of them.

Click Here to get your free tools

Recent Posts

Search

Archives

Automatically logoff inactive users

Post image for Automatically logoff inactive users

by Steve Wiseman on November 16, 2011 · 100 comments

in Tips,Tools,Utility


.

I got a question from Tracy this week:

“Hi Steve. Love all the tools and tips you keep sending our way. Got a question. Is there any easy way to logoff a user when they are not active for say, 15 Minutes?”

I spoke with Tracy further to explain that forcing a logoff could cause data loss.

For example, a user has a Word document open and they walk away. Then boom the forced logoff happens and their document is gone.

MS Word in the trash

In her case she needs it for public facing kiosks. If one of the technicians walks away, it leaves the system wide open.

Locking the workstation for this situation is bad too – since it makes it so the customer cannot use the machine.

Did some googling and found some hacks that used chopped up screen savers that would activate, and then call some logoff code.

Didn’t like that. So I had the team build a little app that would just logoff or lock idle users.

Here is how it works, you call the program like this:

idlelogoff.exe [timeout] [action]

timeout - The number of idle seconds before the action is taken

action - [logoff / lock / shutdown] You can lock, log the user off, shutdown or restart the workstation.

If you wanted a user to get booted off after 5 minutes (300 Seconds) of no activity, You would call it like this:

idlelogoff.exe 300 LOGOFF

If you wanted it to lock the workstation after 30 seconds of no activity this would do the trick

idlelogoff.exe 30 LOCK

If you wanted it to shutdown the workstation after 30 seconds of no activity this would do it:

idlelogoff.exe 30 SHUTDOWN

It has some sanity checking for the timeout. Anything less than 10 seconds is set to 10 seconds.

Call it from the users startup script to make sure it is active while they are logged in.

Get it from our downloads page:

http://www.intelliadmin.com/index.php/downloads/

It is free for personal and commercial use.

One more thing…Subscribe to my newsletter and get 11 free network administrator tools, plus a 30 page user guide so you can get the most out of them. Click Here to get your free tools

Related Articles:

{ 50 comments… read them below or add one }

1 Jeremy October 3, 2012 at 5:34 pm

@Jordan

Create a new OU with only the computers you want this applied to. Then create a new Group Policy and link the OU to the GP. Still create it as a logon script though under user config.

2 Jeremy October 3, 2012 at 5:39 pm

One quick question though. I have this setup using group policy so the .exe is copied from a server, to the C:\. Then a shortcut of the .exe is placed in the startup folder with 1800 LOGOFF. However, when the machine logs in, I am prompted for approval to run this software. Can I run this silently? I have tried .exe /S 1800 LOGOFF but it looks as thoug the software does not load at all with this command.
Thanks

@Colin

Try placing the .exe under “All Users” in the Documents and Settings folder on C:. Are you running a batch file? This application wont run correctly as a startup script so you need to create a batch file and use it as a logon script. Once there just try

START Idlelogoff.exe 30 logoff

3 Jeremy October 3, 2012 at 5:39 pm

@Colin

Try placing the .exe under “All Users” in the Documents and Settings folder on C:. Are you running a batch file? This application wont run correctly as a startup script so you need to create a batch file and use it as a logon script. Once there just try

START Idlelogoff.exe 30 logoff

4 Steve Wiseman October 3, 2012 at 10:13 pm

Hi Jeremy,

The approval message is not coming from our program…but from windows. I suspect it is the same machine you downloaded it from…I think on other computers it should not ask you for approval since it is signed with our certificate.

Thanks,

Steve

5 Steve Enemark October 4, 2012 at 1:33 pm

I just tried copying the .exe and renaming it so I have logoff.exe & lock.exe. I created two batch files and ran them in succession, and the second batch file is the one that actually works.

I watch my list of processes with Task Manager, and can see “lock.exe” appear on the list, then it disappears when I ran my second batch file, and “logoff.exe” appears.

6 shlomi October 16, 2012 at 10:22 am

not working for me 🙁
tried to run from dos (windows xp home sp 3 , local language),

The NTVDM CPU has encountered an illegal instruction.

CS:1199 IP: 037f OP:2e 63 6f 6d 2f

choose “close” to terminate the application

7 Steve Wiseman October 18, 2012 at 1:14 pm

Sounds like your download was corrupted. I would try downloading it again..and it should work

8 Buzz November 27, 2012 at 9:23 am

@29 tested, nice tool with lots of options. not free, but hey choice is good.

9 Hilary Clegg December 10, 2012 at 4:35 pm

Im attempting to use this utility within a Citrix envirnment to lock sessions after 15 min. I’m launching the utility from a logon script with the paramater to lock the computer after 900 seconds. We need this to lock published application sessions (vs. published desktops using screen saver). This functionality works great except that having the idlelogoff.exe process active when a user goes to log out from a published application session is preventing the session from being closed properly. I added idlelogoff.exe into the locoffchecksysmodules registry string value but no dice. (http://support.citrix.com/article/CTX891671) I opened a case with Citrix on the problem and they had me collect process dumps and a full system dump. They looed at the dumps and are saying that the application is waiting on a post quit message. Can an update be made to make this utility close gracefully in my scenario? I apreciate any help you may be able to provide and thank you for your efforts in making this usefull tool!

10 Steve Wiseman December 11, 2012 at 1:12 pm

Hi Hilary,

Any idea what message is sent to apps when the session ends? Normally a post quit message is sent on logoff.

Thanks,

Steve

11 mcgreedy May 26, 2013 at 1:32 am

It would be super awesome pretty pretty please to have an option for this to spawn an arbitrary command in the Windows console environment 🙂 🙂

For example the ACTION options could be [logoff / lock / shutdown / command ].

And/or it would be awesome to know the source code that comprises this wondrous tool, that I may so adapt it for said purpose.

12 Steve Wiseman May 27, 2013 at 8:12 pm

Hi McGreedy,

That is an interesting idea. We will look into it for the next version. Unfortunately we cannot make the source available. It uses our internal API which is used for line of commercial products.

Thanks,

Steve

13 jason July 3, 2013 at 12:07 pm

This is a fantastic option. I have been using a bunch of different screensaver options and they are a nightmare. They need registry changes to at least function inconsistently.

Currently testing it for deployment. My only gripe is there isn’t an option to give a user a chance to cancel.

Typically my users logs in for five minutes and then takes off to log into another machine for one reason or another. If the off chance they are standing in front of the computer picking there nose for 5 minutes; I would like to give them a chance to cancel the log off. A little pop up that tells them they have a minute to cancel the logoff would be nice.

14 HRohal September 6, 2013 at 10:56 am

Thanks Steve,

Is there is was to use it for a specific user?
Is it a kind of check which keeps checking the status and take action once we run it?

15 James Biter November 1, 2013 at 10:54 am

Steve,

I am trying to set up idlelogoff to run as a service, using srvany, but cannot seem to get the command paramters to work (paramters being used are: 180 LOCK. Any insight would be appreciated.
Thanks !

16 Steve Wiseman November 8, 2013 at 11:41 am

Hi James,

I don’t think that will work. The problem with running it in the service context is that it won’t have access to the users desktop. It is possible to run from a service, but it would have to be carefully constructed to watch the desktop session and then unload and reload the program if the session changes.

If you are looking for a way to keep users from getting rid of it, you could use a group policy logon script…just make sure it is a user policy and not a computer policy…that way it runs in the user context.

Steve

17 Perry M November 19, 2013 at 4:03 pm

So we are looking to use something like this in an educational lab environment. Currently, we have our screensaver set so that after 15 minutes, it locks the screen.

We want to have it log the user off after 30 minutes of no activity, as long as they are not ‘rendering’ images in 3d-studio, or other CAD applications.

So what is the definition of ‘idle’? No keyboard or mouse input for X # of minutes?

Could this program be modified so that it will only log the user off if the CPU is also Idle? (or very little usage)? Typically when a user sets up a rendering job, it could run for 18 hours, and we don’t want it to log the user off if the CPU is processing a render job. Perhaps adding a setting for it to only log off the user if CPU usage is less than a specified % for a specified amount of time…

18 Ben November 21, 2013 at 6:23 am

Is it possible to get the program to lock after 30 seconds, logout after 15 minutes and shutdown after 1 hour?

19 Steve Wiseman November 22, 2013 at 2:06 pm

Idle is defined as Mouse or keyboard activity.

Using CPU usage will always be problematic…since every computer handles this differently.

For example, on an older PC a program might take 10% CPU time on average.

On a new, high end system it might bounce around 1%~0%

The problem now is that you would need to tweak this for every system.

I don’t think it would be too hard for us to add CPU% for X minutes then do Y…but you would just need to test and make sure it works for your situation.

20 Daniel January 28, 2014 at 3:22 pm

Will the following command work in our logon.bat?

\\domain.local\netlogon\ifmember /v “domain\Agents” start \\domain.local\netlogon\idlelogoff.exe 600 LOGOFF

Or, do I need this executable to reside on the local drive of the machine and perform start c:\windows\idlelogoff 600 LOGOFF as an example?

21 Justin February 6, 2014 at 12:36 pm

This worked great. Just what I needed. This is super easy to setup.

I dropped the idlelogoff.exe into the root of C:/

Go to “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Startup” and create a batch file.

To do this, open a notepad and enter the following:
START C:\idlelogoff.exe 300 LOGOFF

You can change the syntax for whatever process you need to run. Save the file as a .bat file and move it to the directory above.

Log out and back in to test. 5 Minutes of Idle time and you now get logged out.

22 Mike Teehan May 5, 2014 at 4:00 pm

What is the maximum timeout I can use before logout? I’ve tried using 172800 seconds (should be two days?) and after 3 days I was still logged in.

23 Mark August 22, 2014 at 2:20 pm

My question is similar to #18 of Ben above. I wanted to test it as a lock first followed by a logoff. I put in as idlelogoff.exe 30 LOCK followed by idlelogoff.exe 60 LOGOFF. The first command appears to have run fine as the unit locked after 30 seconds, but the 2nd instance never fired off. I figured that if only one of them would have executed, it should have been the second instance replacing the first but this was not the case. How would more than one instance of this be able to be used to complete more than 1 task (a lock, followed by a logoff)?

Thanks

24 Mark August 22, 2014 at 2:52 pm

Barring being able to use 2 instances, I did manage to accomplish what I wanted doing it the following way:

1) GPO User policy to set a screensaver to launch after a specified time and password protect it.

2) An instance of idlelogoff running in the background from GPU user logon script with the specified amount of time to logoff after the screensaver kicks in.

This gives the user a certain amount of time after the screensaver kicks in to log in without losing anything.

25 Janko October 10, 2014 at 6:40 pm

How about to extend the program to run a batch file after idle timeout?

26 Hossain Bayat January 10, 2015 at 8:48 pm

LogOff, Shutdown and Lock are great options, but can this tool “Restart” the PC as well?

Thanks.

H. Bayat

27 Steve Wiseman February 13, 2015 at 6:46 am

Hello Hossain,

Sounds like an interesting idea. We might add this in the next version.

28 dan wyen February 26, 2015 at 1:39 pm

I agree – please add RESTART

29 Jay March 4, 2015 at 9:31 am

Another vote for RESTART!

30 Steve Wiseman March 10, 2015 at 3:53 am

Hello Everyone,

Here is a new version with the restart option:

http://ftp.intelliadmin.com/release/idlelogoff.exe

Let us know if you run into any problems by sending an email to support@intelliadmin.com

31 dan wyen March 10, 2015 at 10:35 am

Thanks for the effort on the RESTART

32 Cashmoney April 29, 2015 at 9:02 am

This is for someone looking for a detail information of deploying it using GPO on a domain controller.
1. download the application i.e. idlelogoff.exe
2.Create a folder e.g. idlelogoff
3. Put the file you just downloaded into the folder.
4. create a batch file using notepad to call the program you downloaded. e.g., “start c:\idlelogoff\idlelogoff.exe 300 LOGOFF/RESTART/ETC (Make your choice)
5. Share the folder you just created to everyone/specifically (make your choice)
6.Create an OU and place the computer you want it to apply to the OU.
7. Go to group policy and create a gp e.g., idlelogoff and link it to the OU you just created.
8. Edit the gpo from computer configuration>Admin templates>systems>Logon, choose Run these programs at user logon and put the file directly e.g., c:\idlelogoff\idlelogoff.exe
apply it.
9. From the user confi, select Policies>Windows settings>scripts(Logon/Logout), double click logoff and specify the path that contains your script you wrote, e.g., c:\idlelogoff\script

Hope that helps someone.

33 Ture Nilsson May 19, 2015 at 3:18 am

Idlelogoff.exe 20 LOCK
This locks the computer when i’m watching movies and that is a problem. How can I solve this?

34 Dan Peterson May 26, 2015 at 5:35 pm

What is the maximum timeout?

35 matt June 10, 2015 at 11:40 am

Hi. Is there a way to cancel this. Say I want to start a huge download and the logoff timer is ticking, would be great to be able to send a command, maybe: idlelogoff.exe 0 CANCELALL

36 matt June 10, 2015 at 11:42 am

or… will it work to ENDTASK idlelogoff.exe?

37 Zach June 11, 2015 at 3:19 pm

Suggestion for the tool
1st Suggestion
Add a Message box to the user whats going on
Example idlelogoff.exe 300 LOGOFF Message: AUTO LOG OFF, 60 SEC TO SAVE YOUR WORK!

2nd suggestion. Write to the even viewer so when users say it crashed the eventview tells the admin the PC shutdown or logoff because of the PC was not active.

3rd, Give the user a message that the PC is about to log off, give the user an option to stop the log off process.
Example I happen to be doing email on a 2nd PC, the message may remind me to get back to work.

38 Sean Carson July 2, 2015 at 4:40 pm

Hello,

I am curious as to whether or not you can create a scheduled task with this .exe file without having to call from a batch file.

39 Steve Wiseman July 29, 2015 at 12:32 pm

The other way matt would be to kill idlelogoff.exe

That does sound like a good feature to add. I will put it on our list.

40 Steve Wiseman July 29, 2015 at 12:35 pm

Hi Dan,

I believe it may be the maximum 32 bit signed integer. This would be around 2 million seconds. Which is about 500 days.

41 Steve Wiseman July 29, 2015 at 12:37 pm

Hi Ture,

I don’t know if there is a way for us to detect this. Usually when a program goes full screen it takes the action to disable the screen saver. It is not going to ‘know’ about idle logoff. So really in this situation idlelogoff is not going to be a good solution.

42 Wesley October 8, 2015 at 11:55 pm

Can anyone confirm that idlelogoff.exe does not work when explorer.exe is not running? Running thin clients in kiosk mode, and I’m not able to startup idlelogoff.exe automatically.

43 Carter Braxton December 2, 2015 at 12:41 am

This is a great little utility!

Will idlelogoff work for a situation where there are multiple users logged in? We tend to have more than one person using each PC during the course of the day and of course they do not log out when they are done. So we sometimes wind up with 10 or more users logged into a PC simultaneously.

If each user has a logon script that launches idlelogoff of course that will result in multiple copies active with each user having his/her own idlelgoff process. Will this work OK?

44 Jason December 9, 2015 at 10:38 am

I just wanted to say thanks for a great product.. and share how I use the product in our company (about 1000 pc’s)

I create a bat file named GMG-logoff.bat and rename idlelogoff.exe to GMG-logoff.exe. I then placed the 2 files together in a folder and used bat2exe to create a new .exe..

I then push this .exe to all pc’s I want it installeld on in the public “all user” startup folder.. so each user that logs in to the PC will have it running.. I also have it set to 6 hours, this way it forces all users to log off every night..And any user that switched user and forgot gets logged off without the other logged on user even knowing about it!

I then noticed that because of the bat2exe creation, every time it was launched it would create a temp folder with a new instance of the file..

So I had to create a new .bat file and added more code to the new file named logoff.bat that keeps the temp folder clean of these temp files/folders..
I then placed all 3 files (and an ico file) into a folder and recreated a new .exe with bat2exe, this new file GMG-logoff.exe is then pushed to all PC’s that it is needed on to the Public “all user” startup folder..
Just thought I would share..

Again thanks for a great product!

The bat files I use..:

1st file GMG-logoff.bat
includes:

start logoff.bat

++++++++++++++++++++++++++++++++

2nd file logoff.bat
includes:

Echo off
cls

set mypath=%cd%
set mytemp=%temp%\7ZipSfx.000
set mytemp1=%temp%\7ZipSfx.001

if %mypath% == %mytemp% (goto :process)
if %mypath% == %mytemp1% (goto :process2)

RD /S /Q %temp%\7ZipSfx.001
RD /S /Q %temp%\7ZipSfx.000
START GMGlogoff.exe 21600 logoff
goto :end

:process
if exist “%temp%\7Zipsfx.001” (RD /S /Q %temp%\7ZipSfx.001) else (goto :start)

START GMGlogoff.exe 21600 logoff
goto :end

:process2
if exist “%temp%\7Zipsfx.000” (RD /S /Q %temp%\7ZipSfx.000) else (goto :start)

START GMGlogoff.exe 21600 logoff
goto :end

:start
START GMGlogoff.exe 21600 logoff

:end
exit

45 J January 10, 2016 at 6:20 pm

I have some users that log into a Win7 VM remotely. They frequently just close the terminal session instead of logging out. Would this work for them also?
They are just logging in and using a database application so not active unsaved data.

46 Steve Wiseman March 24, 2016 at 10:03 am

That I am not sure of. The best way would be to give it a shot

47 Dano March 29, 2016 at 11:20 am

If you are watching a video (youtube in window, not maximized) without touching the mouse or keyboard, idlelogoff will count that as inactivity and log you off. Is there a fix for this?

48 Nick Parker April 25, 2016 at 10:51 pm

Steve

I’m testing this at work; it would be perfect for our Pharmacy users who bounce from pc to pc all day. However we are in a locked-down environment, and in my testing it only works properly if the user is a local Admin. It doesn’t log off non-Admin users. Any way to get this to work for non-Admins?

Thanks
Nick

49 Steve Wiseman May 10, 2016 at 12:39 am

Hello Nick,

It should work fine for non-admin accounts. We will have to do some testing here and see what is going on. It could be that the account needs a specific right to send the logoff command.

It may be we need to call a different api to do this.

50 Steve Wiseman May 10, 2016 at 12:49 am

Hello Dano,

idlelogoff only looks at mouse and keyboard input. It has no knowledge of what is running currently. This is something we need to look at in a future version. Thanks!

Leave a Comment

Category Links - Windows Forum - Exchange Forum