Created
April 9, 2015 10:15
-
-
Save ereli/a0faf53e417403df8863 to your computer and use it in GitHub Desktop.
prevent screensaver and workstation lockout - vbs script that presses the numlock key twice every 10 seconds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ref: http://superuser.com/a/836346 | |
Dim objResult | |
Set objShell = WScript.CreateObject("WScript.Shell") | |
i = 0 | |
Do While i = 0 | |
objResult = objShell.sendkeys("{NUMLOCK}{NUMLOCK}") | |
Wscript.Sleep (10000) | |
Loop |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had a similar problem but the double numberlock toggle on off every ~6 seconds would miss the repeat and would unexpectedly toggle the number lock on and off. Played incessantly with adding some type of wait / pause / sleep before between or after the numlock strokes to get a timing that would consistently toggle off and back to on reliably.
I finally found a suggestion somewhere on the internet that fixed the whole issue with trying to use Numlock as the keep alive keystroke. Instead of NumLock I used a single keystroke of the F13 key... which in Windows is not on the physical keyboard but is included as a defined key by the operating system (apparently there are F13 thru F24 keys similarly available although I have only tried this with the F13 keystroke).
So the keep alive script (that prevents lock and screensaver) that I finally got to work on my physical workstation ..
and the VM Ware Horizon virtual Win 11 desktop (Note: worked fine in Win10 version before we upgraded) is below...
Dim objResult
Set objShell = WScript.CreateObject("WScript.Shell")
Do While True
objResult = objShell.sendkeys("{F13}")
Wscript.Sleep (6000)
Loop
It probably could be more elegant ... or have more defining features (ie a timeout or run time parameter) but I basically stopped working on it once I found an incarnation that worked.
Oh and if I need to stop it a reboot will do it ...
or I will simply do a Ctrl Alt Delete and end task on Microsoft Windows Script Based Host wscript.exe that is running in Task Manager. Not a demanding task in terms of memory space use .. usually occupying/allocating .3 MB when running in Win 10 and ~1.0 MB running in the Win 11 virtual instance.