I have a script that I’m running as a logon task scheduler to move the mouse every 10 minutes because I want to keep windows from locking out after inactivity. I can see the task scheduler is running the task at logon and mouse is moved after 10 minutes.
Is it because if no one moves the mouse after the script is run, the mouse is just being moved at the same place? Would random mouse move work?
Thanks for the reply. I have a script that open and closes Notepad every 10 minutes, and so far its working. I had the script running since Friday and its still logged on.
I’m sure there might be a better way, but this should work for what I need.
I tried the Windows GPO to stop logging out of inactivity, but for some reason its not working. I can see the gpo when I run gpresults, but I guess there’s some other GP that’s over ruling it.
Your Stop-Process will exit all Notepad processes. Is this what you really want to do?
You will have Notepad windows popping up, taking focus, and then disappearing after 5 seconds which would not be conducive to working
A far better solution would be to toggle ScrollLock on and then off again with your desired frequency. No windows popping open, not exiting processes that you actually want to run
From my experience it is difference because I have a batch file plus a Vbscript that toggles ScrollLock and it prevents my computer from locking. I’ve never translated it to Powershell as I have no need to.
set WshShell = WScript.CreateObject("WScript.Shell")
dim varHour, varInterval
If WScript.Arguments.Count = 0 Then
varHour = 1
varInterval = 4
End If
If WScript.Arguments.Count = 1 Then
varHour = CInt(WScript.Arguments(0))
varInterval = 4
End If
If WScript.Arguments.Count >= 2 Then
varHour = CInt(WScript.Arguments(0))
varInterval = CInt(WScript.Arguments(1))
End If
StartTime = Now
EndTime = DateAdd("h", varHour, StartTime)
WScript.Echo "Beginning at " & StartTime & " estimated end time of: " & EndTime
WScript.Echo "This will run " & varHour & " hour(s) and interval is every " & varInterval & " minutes."
Do While Now < EndTime
WScript.Echo "Toggling ScrollLock at: " & Now & " estimated end time of: " & EndTime
WshShell.SendKeys "{SCROLLLOCK}"
WScript.Sleep 100
WshShell.SendKeys "{SCROLLLOCK}"
'); // Toggle Scroll Lock
WScript.Echo "Sleeping for " & varInterval & " minutes. Press Ctrl-C to exit."
WScript.Sleep (varInterval * 60 * 1000)
Loop ' or use this syntax
WScript.Echo "Ended at: " & Now
I have to ask out of curiosity why you want the screen to not lock? The ScreenLock is a common/best practice from a security standpoint and it seems very quirky to have an endless loop running when you could just configure GPO?
Right, I agree the screen lock is a good practice for security. The reason is because these computers will be used to track the progress of work the employees are doing. I work for a manufacturing company. So it will be easier for the users and for me as IT if they don’t have to login every few minutes. Plus less chance of keyboard / mouse from getting dirty etc. Its a unique situation.
These computers have no internet access, and only very specific areas to LAN, plus Sophos etc.
I know its not the best recommended method, but because of the nature of business, this is how they want it done.