Keep the system active, to avoid the auto lock

Most of the corporate offices will have a policy for screen locking. While working with a long running applications at background, like the automation scripts for testing the applications, it would be difficult to maintain the unlock state of the screen. Thus, we found a technique to keep the system active with a cheating technique.

Below is the powershall scripts that keeps the system active

' I am clicking on NUMLOCK for every 5 seconds to keep the system awake
Set objNetwork = CreateObject("Wscript.Network")'to get user name
numOfHours=inputbox("Hi " & objNetwork.UserName & ", How many hours you want me to be awake? :->") 'time variable conatins the time in hours
Set WshShell = WScript.CreateObject("WScript.Shell") 'Creating an object for clicking keys from keyboard
numOfMilliSecs=numOfHours*3600*1000 'converting hours to milli seconds
While numOfMilliSecs>0 'runs until tym becomes zero
WshShell.SendKeys "{NUMLOCK}" 'clicking on NUMLOCK
Wscript.Sleep 5000 'sleep for 5 seconds
numOfMilliSecs=numOfMilliSecs-5000 'decreasing time by 5 seconds
Wend 'end of loop

Everyone is allowed to copy and use or modify at your style.

-----------------------
If you have something to share in person on this post, pl drop me a mail at dskcheck@gmail.com with the title in the subject.

Comments

Popular posts from this blog

Network Intrusion Detection using Supervised ML technique

Common mistakes by Interviewer