Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent auto-locking feature of an XP machine using VBscript

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?

like image 530
Srivi Avatar asked Dec 16 '10 06:12

Srivi


People also ask

How do I sleep in VBScript?

Suspend the execution of the current script for the specified number of milliseconds. Sleep is a wscript method. WScript. Sleep(5000) WScript.


2 Answers

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
like image 187
st0le Avatar answered Oct 24 '22 21:10

st0le


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.

like image 20
Graham_Edwards Avatar answered Oct 24 '22 20:10

Graham_Edwards