Simple VB Script code to prevent my system from locking

This is common problem that we encounter that we have automate our suite and run the same at any given time.

However we can schedule the scripts using windows scheduler or other alternative but problem arises when we need to run the scripts unattended.

For that i have developed and tested a vb script that will not attack on existing running functionality and also prevent the system from locking.


'Step 1:Create WScript Object
set wscrpt = CreateObject("WScript.Shell")

'Step 2:Run the Loop so that system repeated again and again.
Do

WScript.Sleep (10*1000)  'Set the timer for number of seconds.Here i am setting 10 seconds.

wsc.SendKeys ("{SCROLLLOCK 2}") 'Use Send Keys to press the keyboard control.

Loop  ' End Loop


Steps To run above Code

Step 1:Copy the above code into notepad file as it is.

Step 2:Save the file with any logical name you want but with .vbs extension to convert the notepad file into vb script executable file.

Step 3:Double click the the file it will start running.



Comments

  1. Thank you again for all the knowledge you distribute,Good post. I was very interested in the article, it's quite inspiring I should admit. I like visiting you site since I always come across interesting articles like this one.Great Job, I greatly appreciate that.Do Keep sharing! Regards, AdLock Media

    ReplyDelete
  2. Hi Anshul,
    Just found this link.
    Tried this code. But while double click on, it doesn't work. Any reason behind this ?

    ReplyDelete
  3. I used this and it works perfectly. Is there any risk that this file will be seen/found as a questionable file type?

    ReplyDelete
  4. Hi ..I am getting an error which reads Run time error '424': Object required. And reference is set to Wscript.Sleep (10*1000)

    ReplyDelete
  5. please update this code wsc.SendKeys ("{SCROLLLOCK 2}") as
    wscrpt.SendKeys ("{SCROLLLOCK 2}")

    ReplyDelete
  6. how can we stop the script if we want to stop then?

    ReplyDelete
  7. Cmd prompt execute this then hit Enter >> tasklist /FI "IMAGENAME eq wscript.exe"

    ReplyDelete
  8. Instead wsc.SendKeys ("{SCROLLLOCK 2}") , it should be
    wscrpt.SendKeys ("{SCROLLLOCK 2}")

    ReplyDelete
  9. Go go to your task Manager and you will find a task with name - Microsoft Windows Based Script Host. Kill the task and it will stop running the script.

    ReplyDelete

Post a Comment