I am automating a process and automation will be running 24*7. Automation will be running on client system and that system automatically get locked after 10 mins because of this automation stopped.
I don't have permission to change the settings.
I want to prevent auto lock by generating event either mouse event or keystroke. Is it possible through JavaScript or Is there better way to achieve the same?
OS:Window 7
Any suggestion will be help.
After doing bit of research on various forum I had figured out that we can keep system unlock with the help of below JavaScript code:
function fnPreventWinLock() {
var wsc = new ActiveXObject('WScript.Shell');
wsc.SendKeys ("{SCROLLLOCK}");
wsc = null ;
}
Call this above function after certain amount of time (Say:5 mins) with window.setTimeout()
function to keep system unlock.
I have made a very simple and easy to use script(.bat) which disabled autolock by running the script in a console(cmd) window. If you want to stop the script, the user just need to close the console window.
:: SAVE this script as a .bat file and execute it to disable autolock
@echo off
COLOR 0A
mode 69,9
title Stay Awake
echo Dim objResult > %temp%\stay_awake.vbs
echo Set objShell = WScript.CreateObject("WScript.Shell") >> %temp%\stay_awake.vbs
echo Do While True >> %temp%\stay_awake.vbs
echo objResult = objShell.sendkeys("{NUMLOCK}{NUMLOCK}") >> %temp%\stay_awake.vbs
echo Wscript.Sleep (5000) >> %temp%\stay_awake.vbs
echo Loop >> %temp%\stay_awake.vbs
echo Start Time: %date% %time%
ECHO Please close this window to stop the Stay_Awake Script
echo.
cscript %temp%\stay_awake.vbs
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.