How can I prevent a policy-enforced screen lock in Windows?

Our corporate BOFH imposes the screen lock setting with a ridiculously short delay. It's frustrating and counterproductive.

Is there a way to prevent the automatic screen lock? I would assume there is no way to override the policy-enforced setting, but maybe there is a software that mimics user activity.

Just asking before I set up a perpetual mouse wheel. (get it?)


Yet another option is freeware Caffeine program. It is free for commercial use as well. From the program's homepage:

If you have problems with your PC locking or going to sleep, caffeine will keep it awake. It works by simulating a key-press once every 59 seconds, so your machine thinks you're still working at the keyboard, so won't lock the screen or activate the screensaver.

Caffeine works by simulating an F15 key up event every 59 seconds. Of all the key presses available, F15 is probably the least intrusive (I've never seen a PC keyboard with that key!), and least likely to interfere with your work.

This off-the-shelf solution also allows you to control when to enable it and disable it:

Double-clicking the program icon empties the coffee pot, which is what the icon represents, and temporarily disables the program. Double-clicking it again refills the pot, and will keep your machine awake.


If Windows Media Player is still installed, you can play a video on loop and minimize it (the sample "Wildlife" videos work fine for this). By default, as long as a video is playing, the screen won't lock.


I use a script I title idle.vbs:

Dim objResult

Set objShell = WScript.CreateObject("WScript.Shell")    

Do While True
  objResult = objShell.sendkeys("{NUMLOCK}{NUMLOCK}")
  Wscript.Sleep (6000)
Loop

Every six seconds, this quickly toggles numlock on the keyboard, causing Windows to believe that someone is interacting with the keyboard, preventing screen lock. This runs on vanilla windows, you don't need development or scripting tools to use it, just make a text file with .vbs as the extension and double-click it (or place it in your startup items).

Edit: you can put this script in your startup items with

 choco install IdleVbs -source https://www.myget.org/F/joshrivers-utility/

For more information on the Choclatey (choco) CLI installer please see:

https://chocolatey.org/


You can create an AutoIt script to either continually press an unused key (e.g. make it toggle the num lock, scroll lock), sleep for a minute or so, and repeat. Alternatively, if you use the keyboard a lot, you could make it move the mouse by a pixel or so in any direction.

If you don't want it continually running, you could also launch the script as a scheduled task (if you have access) to launch after the computer has been inactive for some time.

And this is a very simple script to perform an invisible mouse move, if you don't want to get into AutoIt syntax:

While True
   Local $pos = MouseGetPos()
   MouseMove($pos[0]-1, $pos[1]-1, 0)
   MouseMove($pos[0], $pos[1], 0)
   Sleep(540000)
WEnd

This script moves mouse cursor by one pixel in the up-left direction and after that returns it back, then sleeps for 9 minutes (540000 milliseconds). When script is running, you can see AutoIt icon in the tray. You can stop it right-clicking this icon and choosing the corresponding option.

To make a script, install AutoIt, right-click in any folder and choose New > AutoIt v3 Script, name it, right-click this new script, choose Edit, paste the code provided above and save. You can even compile it to .exe (again, from context menu) to start, for example, from Windows Scheduler.


I like to use easy and integrated options (no additional software), like a powershell script (thanks https://dmitrysotnikov.wordpress.com/2009/06/29/prevent-desktop-lock-or-screensaver-with-powershell/) that uses the "f15" as the key to success (thx to caffeine. It's indeed least interfering)

param($minutes = 180)

write "... screen will be awake for $minutes"

 $myshell = New-Object -com "Wscript.Shell"

 for ($i = 0; $i -lt $minutes; $i++) {
 write "... screen will be awake for" ($minutes-$i)
 Start-Sleep -Seconds 60    
 $myshell.sendkeys("{F15}")
}

Put this into a myScriptName.ps1 and start it via desktop shortcut or commandline: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -nop "C:\Users\myUser\Desktop\myScriptName.ps1"

UPDATE: Maybe there was some change from the administrator, but this doesn't work for me anymore Now I have to use an autohotkey-script from NBirnel: https://github.com/nbirnel/nosleep - this work perfect, because it moves the mouse (without distracting any work)