At first, happy new year 2019 to you all!
I have been thinking what topic would be my first blog post of year 2019, maybe something about ConfigMgr or Intune? Turns out, neither! In these two days, I have been make a idle notification/action tool, because I have some needs log off user from machine if user is not using it for xx minutes, it needs to have popup notifications, custom text, time out features, and most important: Do some actions, example log off the user. Basically this is useful for public use machines or shared PCs, Kiosk PCs.
I found this Idle detection code from Andy Arismendi : https://stackoverflow.com/questions/15845508/get-idle-time-of-machine , it works very well, this helped me maked my own Idle notification tool. This is how it looks like:
How does it work
After installation, it puts IdleNotification.lnk shortcut in folder C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp, when user logon, it runs IdleNotification.exe in background, it checks idle status every 10 seconds. After installation, you have to log off then log in again, so that Idle Notification.exe will automatically start. Based on your configuration, it will popup a custom notification when reach to xx minutes idle time, this notification will stay on your desktop xx minutes unless you click OK. Idle time will be reset to 0 if someone use mouse or keyboard.
What this tool can do and how to configure it
- All the properties are stored in settings.xml file, which can be configured as how you like.
- You will need to put all these three files in one folder, then create a shortcut for IdleNotification.exe
- Put the shortcut to C:\ProgramData\Microsoft\Windows\Start Menu\Programs\StartUp folder, so that this app will start automatically when user login.
Here are the configurable properties
TITLE
Input the title you like, usually is your company name
IMAGEFILE
You can configure your own image, it supports max. 300 x 80 pixels jpg file. You must copy the file to same installation folder as this tool, in my case is C:\Program Files\IdleNotification, configure the property IMAGEFILE value to your logo image file name.
IDLETIMEMINUTES
Here you can configure idle time in minutes. The default value is 5 minutes, I have hardcoded that check each 10 seconds idle status, so there are some delays.
BODYTEXT
This is the text saying This computer has not been used for 5 minutes, you will be logged off soon. If you wish to continue use it, please click ‘OK’
NOTE: Please don’t input too many characters, otherwise it will push log off time and OK button out of the notification box.
COUNTDOWNMINUTES
This is how long popup notification will stay on your desktop by minutes. The default is 2.
DEADLINETEXT
This is the text saying Log off time, details of log off time is calculated in the app, I made this property just in case you want to change it to your local language.
DOACTION
I originally only wanted to log off the user, but I didn’t hardcode this action, you can configure other commands. Default is shutdown.exe /l /f, this command will force log off the current user.
STARTTIMEMINUTES
You can use this configure what time do you want it checks idle time, example if you want starts at 8am, use value 480, calculate 8 time 60 minutes, so it’s 480. Default is 0
You can use PowerShell calculate this value as well, example: ## calulate 8AM
(New-Timespan -Hours 8).TotalMinutes
## Calculate 5PM
(New-Timespan -Hours 17).TotalMinutes
DURATIONMINUTES
Use this property configure how long do you it checks idle time since StartTime. Example, you want configure it check idle time from 8am to 5pm, configure STARTTIMEMINUTES as 480, DURATIONMINUTES 540. Default is 1440
You can use PowerShell calculate these values as well, for example :
# From 8AM to 5PM
(New-TimeSpan -Hours (17-8)).TotalMinutes
#From 10PM to next day 8AM
(New-TimeSpan -Hours (24-22+8)).TotalMinutes
DETECTLOCK
Default is False, if set it to True, it will detect locked status, and it will not do anything if user locked the machine. But if user locked the machine after idle notification appears and didn’t choose OK, it will still log off the user.
DETECTSLIDESHOW
Default is False. If set it to True, it will detect if PowerPoint SlidesShow is on, it will not anything. However, if user start SlideShow after notification appear and didn’t choose OK, it will still log off the user. Set it to False if you don’t want the dectection
PROCESS-NAME
In here you can configure process names, if the process is running, Idle tool will not do any actions. You can add more processes by adding <Name>your process</Name>
Download
You can download this tool from my GitHub: Click here
Update History:
- Version 3.0.3.0 (April.18.2019) Fixed bug that popup windows doesn’t work if there are special characters (Thanks for Maurice’s help)
- Version 2.0.1 (April.03.2019) Fixed a bug that action didn’t run.
- Version 2.0.0 (March.31.2019) Added detect running process. Note, I no longer offer the ready msi package, you will have to pack all the files and deploy them.
- Version 1.0.6 (Jan.25.2019) Fixed a bug that body text property was not applied.
- Version 1.0.5 (Jan.11.2019) Added property DETECTSLIDESHOW. Default is True, if PowerPoint SlidesShow is on, it will not anything. However, if user start SlideShow after notification appear and didn’t choose OK, it will still log off the user. Set it to False if you don’t want the dectection
- Version 1.0.4 (Jan.10.2019) Added Padding in textbox, so that text are not in the edge of textbox
- Version 1.0.3 (Jan.10.2019) Added property DETECTLOCK, Default is True, it will not do anything if user locked the machine. However, if user locked the machine after notification appear and didn’t choose OK, it will still log off the user. Set it to False iif you don’t want the dectection
- Version 1.0.1 (Jan.10.2019) Added two properties, can now use between time frames
- Version 1.0.0 (Jan.07.2019) First version.
Hi Sandy
Apologies for the extremely long delay in responding, I thought I would get a notification when this post was updated. Thank you for taking the time to test, much appreciated.
I haven’t had a chance to deploy the newer version yet as we have a number of different setups in our environment now to accommodate the new way of working for a lot of people.
The last time I checked the original version back in December it seemed like if the rdp session was in focus the app would timeout and exit without reboot, but if not in focus it seemed to disconnect/logoff – i have not been able to trace anything else logging off/rebooting at the same time. When tested on site with console logins the app worked as expected as well, just the sessions over rdp were not behaving the same way.
Aside from that we found that having implemented FSLogix some of our users were getting login issues in relation to that and the error that displayed was ignored and the device presumably abandoned with that error on screen awaiting input so the idle timer never got to start anyway. We have set a nightly restart on all our devices now to clear issues.
No longer located at (https://gallery.technet.microsoft.com/Idle-Notification-and-7230b245)
Hello, it’s in my GitHub now https://github.com/sandytsang/IdleNotification/releases/tag/v3.0.3.1, just updated the post. Thanks!
Hi, We are trying to utilise this tool but are seeing some strange behaviour that as yet I cannot understand. If we set the values to 30 minutes idle and 10 minute popup display we get on W10 2004 the popup exits as expected on time but logoff doesnt happen or the popup exits and is replaced seconds later by another one with a new 10 minute logoff time on it and when this happens it seems to keep repeating. If we set the values to 20 minutes and a 9 minute countdown it seems to work as expected, same if we drop those values to 2 minutes and 5 minute countdown for testing. Has anyone else encountered anything like this?
Hi Pete, I will test this when I find time, need debug a bit and wait 30 minutes do nothing, that can be challenge for me. 🙂 I will let you know.
Hi Sandy
Yeah the 30 minute test was a pain, it did work when we first tested it. We then applied the package to ten machines in a test lab and the following day noticed the odd behaviour. I thought perhaps it may be an issue with our testing it over RDP as we are still in a work from home scenario in our environment. I have just tried it via a console logon on a random live machine and after the 30 minutes, the popup appeared as expected and exited after the time expired but again logoff did not happen. I ran the logoff command from the settings xml as the logged on user via command prompt and it logged off the device.
Kind Regards.
Hi Sandy,
I was on site today and tested this again and it is working as expected now.
I will test it again remotely and see if that now works or exits without logoff.
Kind Regards
Pete
Hi Sandy
Just an update on this one, in our environment the tool is working as expected, only when logged in locally though, when logged in over remote desktop which a lot of our users are currently having to do for social distancing the idle app appears as expected , but once the countdown timer has ran out it just exits and doesn’t logoff the device. I can’t see any reason that the logoff process doesnt take effect.
Kind Regards
Pete
Hello Pete, can you try out this in my GitHub again? https://github.com/sandytsang/IdleNotification/releases/tag/v3.0.3.1, in XML file, use shutdown /l /f . I tested in my virtual machine with the enhanced session (kind of like remote desktop), it did log me out.
How does one go about deploying this via Intune?
You can configure all the settings that you like, then package it as IntuneWin32 apps.
Best creation of 2019!!
2 questions:
How do you recommend deploying this tool via SCCM after the logo & XML files have been customized?
Any plans to add an option to run scripts before logoff??
Hello, I no longer offer the msi ready made package. I would use PSAppDeployToolkit to package these files and deployed them. The action is actually using PowerShell command Invoke-Expression, the settings.xml DOACTION property define the value of $action, you can put in your script run some actions then logoff, right? The tool is not for too complex usage. 🙂
You can download the package again from TechNet, I have packaged those files using PSAppDeployToolkit, but you will need to put your own logo.jpg in file folder.
Thank you! Usually 10% of our 15k computers remain powered on overnight and this software will help us to shutdown idle computers. Here is some suggestions:
1 – Could you allow only 1 instance per user? I’m going to enforce the start in multiple ways (start folder, reg keys and so on) and more than 1 instance running maybe will cause some problems…
2 – Could you allow the running of powershell scripts? I would like to check if some apps (MS Word, for example) is running before logging off/shutdown computer, add some logging and so on. This could be helpful to avoid angry users 🙂
I’m currently using powershell.exe -File C:\test\script.ps1 -ExecutionPolicy ByPass, but it would be nice just point a powershell script in settings.
I wanted to build on the previous comment’s point #2.
It’d be nice if in the settings we could define a list of processes that if running would not log off the user. Some of our labs have users doing extended rendering or processing so if certain executables are running we’d prefer to not do the logoff.
Hi, this tool is exactly what I have been after for quite a while. My clients have a tendency to leave their machines unlocked for an excessive amount of time.
Can I ask, would this still log the user off if the machine is locked? I would like the tool to log people off if they have left it in an insecure state, but if its been locked, do nothing.
As a suggestion, this tool would be even more amazing if it had two actions configurable at two different idle times. ie, lock machine after 5 mins idle, then log user off after an additional 5 mins idle.
Hi, fantastic idea. Been looking for something like this for a while. I have a few enquiries.
1. Is it possible for the app to detect if a video or PowerPoint is full screen? At the moment it ignores this. Windows has a built-in ability to not start an idle timer if it detects either of these.
2. Is it possible for the app to have two actions based on two different idle times? ie, After 5 minutes one command runs, then after another 5 mins, another command runs? I am thinking of a case where initially a machine will lock (I have tested this your app will accept the command “rundll32.exe user32.dll, LockWorkStation”) and then once the second idle timer is triggered, it logs the user off.
3. Is it possible to add some padding to the notification box text so it doesn’t start right at the edge of the box?
Thank you and apologies if that’s quite a lot of requests!
Hello Gregg, I combine your two comments in to one. I have updated my tool, now it can detect locked status, PowerPoint Slide Show and fix the padding. I am not using Windows idle, only idle detection I am using is user input. I see you want use first action lock the machine in x minutes, then after x minutes log off the user, but why not use GPO or Intune configure “Interactive logon>Machine inactivity limit”?
Or are you looking for not using GPO or Intune for inactivity limit, but using this tool to do so. So if user locked the machine by themselves, this tool do nothing. But the tool locked machine in like 5 mins idle, then maybe 60 min. later it log off user? Just curious in what kind of scenario you are having. 🙂
I made this tool, original idea is for shared PC and Kiosk PC, so that it log off the user and delete also profile as well, keeps personal data secured, just in case people forget log off from public computers. 🙂
Regards, Sandy
Great idea. Thank you. How do you check for idle time?
I am using some codes from this discussion. https://stackoverflow.com/questions/15845508/get-idle-time-of-machine
Thats neat. I could really use this for a client, but I would need some method for it to only check after a time. e.g. only perform this check from 7PM onwards – so it didn’t interfere with folk working at night. Possible?
cheers
Dave
Hello Dave, I added two more properties and updated the msi package, would you like try again? Details are in the post.
Regards, Sandy