To Handle Ad Blocker

Prevent Desktop Lock Or Screensaver

Due to administrative rights or group policy, sometimes system get locked or screensaver after timeout. In this situation, most of the Automation Tools (Like Automation Anywhere, UIPath etc) fails to perform the action on the application. There is a little utility (Script Program) that runs in your system tray and prevents your computer from locking or going into screensaver mode as it normally would when idle and while it is not really Symantec related. Even many worker of the Big company has a problem with auto logoff screensaver and they use this little utility to break rules, to make a system works all time, even he goes pi. 😄 I have found it very useful and I thought I would share it.


CREATING VB SCRIPT



Microsoft VBScript (Visual Basic Script) is a general-purpose, lightweight and active scripting language developed by Microsoft that is modeled on Visual Basic. Let's create a simple program for preventing desktop lock or screensaver:

In First Step, we will create an object of WScript.Shell which is an instance of the windows shell allowing us to run commands against the windows shell from within our VBScript program. It is a powerful object that enables us to query and interact with various aspects of the Windows shell. We can display information to the user, run applications, create shortcuts, work with the Registry, and control Windows' environment variables.



In Second Step, we will create a Boolean type variable and assign it default value false



In Third Step, we will create Do Until loop having vFlagStopScreensaver - False as its condition for executing its block of code.

In Last Step, we will place the below two line of the code in the above loop's execution block. First line of code will make our VBScript program to wait/sleep for 60000 milliseconds (1 minutes = 60 Seconds = 60000 milliseconds). Second line of code send/press F15 Key of the keyboard which has no function assign.



Complete code will look like as appearing in the below image. Now save the program with .vbs extension anywhere or with any name (I'll prefer StopScreenSaver.vbs). To test, Double click on the file to run the program. As you will double click, it will start running in the back end.




DEPLOYING VB SCRIPT



If you will run the program after saving anywhere on the system. It will stop running as you will restart the system. But our requirement is that it run when Robot will login the system and perform its actions/activity.

Solution of this problem is that we place this Script file on the Startup folder location so that whenever system restart then it will start running itself. Perform the below steps to do so:

1 - Open Run Command by pressing Win + R
2 - In Run Command Window, type anyone of the below line and press Enter








3 - Copy and Paste the StopScreenSaver.vbs in the Startup Folder and close the folder.


I hope this post is helpful. If you have any questions, feel free to comment it below.

Happy Learning.. :-)