machine get locked during the automation script run-time , this is because there is a long interval between different scripts that(this is required for some reasons) . I want to avoid this auto locking feature. The problem is, as per security policies we cannot disable this feature from control panel. Is there any other way to keep the system unlocked?
Suspend the execution of the current script for the specified number of milliseconds. Sleep is a wscript method. WScript. Sleep(5000) WScript.
I did this...It sends 2 SCROLLLOCK Keys, quickly, so it wont interfere (well, not anything serious anyways) with any applications. It does this every 60 seconds....Cheers!
set wsc = CreateObject("WScript.Shell")
Do
WScript.Sleep (60*1000)
wsc.SendKeys ("{SCROLLLOCK 2}")
Loop
I use a pair of files...
The first file (Keep_Awake__start.vbs) keeps things awake/unlocked. The second file (Keep_Awake__end.vbs) conveniently terminates the process when you want to go back to a normal proces.
The first file...
' Keep_Awake__start.vbs
' Graham Edwards
' Typical stored in Start Menu
'
' Use Keep_Awake__start.vbs to keep the computer from inactivity-based lockouts.
' Use Keep_Awake__end.vbs to remove Keep_Awake__start.vbs
' Largely pulled from st0le response
' Http://stackoverflow.com/questions/4457907/how-to-prevent-auto-locking-feature-of-an-xp-machine-using-vbscript
' --- Define Object
set wsc = CreateObject("WScript.Shell")
' --- Loop every so many minutes and change the scroll lock setting
Do
' Wait for ~2 minutes
WScript.Sleep (2*60*1000)
wsc.SendKeys ("{SCROLLLOCK 2}")
Loop
The second file...
' Keep_Awake__end.vbs
' Graham Edwards
' Use Keep_Awake__start.vbs to keep the computer from inactivity-based lockouts.
' Use Keep_Awake__end.vbs to remove Keep_Awake__start.vbs
' Largely pulled from Ansgar Wiechers response
' http://stackoverflow.com/questions/22324899/kill-a-vbscript-from-another-vbscript
' --- Define Object
Set wmi = GetObject("winmgmts://./root/cimv2")
' --- Search and Destroy
qry = "SELECT * FROM Win32_Process WHERE Name='wscript.exe' AND NOT " & _
"CommandLine LIKE '%" & Replace(WScript.ScriptFullName, "\", "\\") & "%'"
For Each p In wmi.ExecQuery(qry)
p.Terminate
Next
' --- Clean up
Set wmi = Nothing ' Release the Application object
The files can both be created from a regular text editor and stored anywhere (like your desktop). Once you save the file with a .vbs file extension, it is executable. So, you just have to double click on the file icon to get things to start or end (depending on which file you double click).
You could store the Keep_Awake__start.vbs in the Windows Startup folder, so it launches as soon as you log in.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With