How to prevent windows automatic screen lockout (without administrator access)

Most of the organisations set the group policy for screen idle timeout and lockout group policy settings to avoid unauthorised access to corporate computers. But in few causes you might to override these settings, Like running a screen recording, presentation or few want to keep the screen unlocked to keep their Lync/Teams status active. 

But to override the GPO you need local administrator right s to your computer,  which might not be easy to get on most of the enterprise systems.  You can use below powershell script to keep prevent your screen from automatic lockout. 

Powershell code: 

$WShell = New-Object -Com Wscript.Shell

while (1) {$WShell.SendKeys("{SCROLLLOCK}"); sleep 60}

This code simulates a key press on a specific interval to avoid scree timeout or lockout. This particular code sends scrollock key press signal to system at every 60 seconds.  You can change the frequency by changing the value next to sleep.

You can save this code as powershell script( .ps1) and configure a schedule task to automatically tigger when system boots up.  


Note: Some organisation prevent executing powershell scripts by applying group policies. If you are unable to run this code using powershell script manually launch powershell and copy paste this code. This should work for users.


You can use below reference table for more key options. ( For more details about sendkeys visit  https://ss64.com/vb/sendkeys.html )   


Key/CharacterSendKeyDescription
~{~}Send a tilde (~)
!{!}Send an exclamation point (!)
^{^}Send a caret (^)
+{+}Send a plus sign (+)
Backspace{BACKSPACE} or {BKSP} or {BS}Send a Backspace keystroke
Break{BREAK}Send a Break keystroke
Caps Lock{CAPSLOCK}Press the Caps Lock Key (toggle on or off)
Clear{CLEAR}Clear the field
Delete{DELETE} or {DEL}Send a Delete keystroke
Insert{INSERT} or {INS}Send an Insert keystroke
Cursor control arrows{LEFT} / {RIGHT} / {UP} / {DOWN}Send a Left/Right/Up/Down Arrow
End{END}Send an End keystroke
Enter{ENTER} or ~Send an Enter keystroke
Escape{ESCAPE}Send an Esc keystroke
F1 through F16{F1} through {F16}Send a Function keystroke
Help{HELP}Send a Help keystroke
Home{HOME}Send a Home keystroke
Numlock{NUMLOCK}Send a Num Lock keystroke
Page Down
Page Up
{PGDN}
{PGUP}
Send a Page Down or Page Up keystroke
Print Screen{PRTSC}Send a Print Screen keystroke
Scroll lock{SCROLLLOCK}Press the Scroll lock Key (toggle on or off)
TAB{TAB}Send a TAB keystroke

Post a Comment

0 Comments