Thursday, May 16, 2013

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.



3 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