Introduction: VBScript Screen Lock

About: Hello, my name is xp4xbox, a really old name that really has nothing to do with xbox consoles. Anyway I enjoy making programs and have several instructables on some of them. So far, I know VBScript, Batch, Pow…

I have seen many screen locks on the internet, so I decided to try to make one. I decided to publish it because it can be very useful to lock your computer if you don't have a password on it. So I will teach you how to make it. Or just skip to step 6 to download my pre-made one.

This program is not that complicated, all it does is lock your computer with the password that you provided in the file. PS: the cancel button does not work =D.

The program was made using VBScript.

NOTE: If you do not know vbscript, here is a introduction that will help you out, LINK(but if you have basic knowledge of vbs or VB.NET this script should be easy to understand =D)

ALSO NOTE: If you are interested in a free vbseditor, attached below is one. There is also vbsedit which I use.

Step 1: My Script...

Here is two versions of the script......

Choose the right one for your operating system.

Download and extract the zip file, then right-click on Screen Lock.vbs and edit with any text editor, MAKE SURE TO MAXIMIZE THE WINDOW.


Step 2: Your Password

To set your password, enter your password in between the quotes in the file. Passwords are case sensitive.

The way this script works, is that it disables several ctrl-alt-delete options to prevent unauthorized changes while your computer is locked. Then re enables them when you enter the correct password.

NOTE: Since it is impossible to mask password input in vbs, I recommend dragging the application to the bottom of the screen so that the input section is hidden and then typing in the password.

Step 3: Custom Message...

You can edit the message that would appear on the logon screen if the user tried to abort the lock. To set the text, enter your message in between the quotes in the script as in the picture.

Step 4: Adding a Drive Locker...

If you have seen my VBScript Drive Lock you will know that it is possible to lock drive(s) using vbs. So I will teach you how to incorporate into the screen lock.
NOTE: This is an optional feature, by default it is not in the default script or in my pre-made one on step 6.

So first open up notepad and paste the following information:

Objshell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoViewOnDrive", 67108863, "REG_DWORD"

First you will notice the following number '67108863'. This number is telling which drive to be locked. By default, the program will lock all drives, but if you want to lock only one drive, you would have to look at this chart to know which number:

A – 1, B – 2, C – 4, D – 8, E – 16, F – 32, G – 64, H – 128, I – 256, J – 512, K – 1024, L – 2048, M – 4096, N – 8192, O – 16384, P – 32768, Q – 65536, R – 131072, S – 262144, T – 524288, U – 1048576, V – 2097152, W – 4194304, X – 8388608, Y – 16777216, Z – 33554432, ALL – 67108863

So for example if I wanted to lock the C drive, I would replace 67108863 with 4.

Now paste in that code into your vbscript as the location in pic 1.

Now to add the function to unlock the drives once the user has entered the correct password, paste in this code into the vbscript as in pic 2.

Objshell.RegDelete "HKCU\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\NoViewOnDrive"

So now you are done installing the drive lock feature and you can move on to the next step!

NOTE: If you ever forget your password, to unlock the drives, just open up regedit and navigate to (pic 3)

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer\

Right click on NoViewOnDrive and click delete. Log off and on your account to see the changes.

Step 5: Adding the File to the Startup...

To add this file to the startup unless you are using windows xp, first you must change the admin prompts to never notify so that it will lock your computer automatically without prompt.

Then create a shortcut of the .vbs file, drag and drop the file to the start up folder. Here is a link with more details on how to do this: LINK

NOTE: There is another method of making this program automatically run as an administrator without changing the settings for all programs, if you are interested click here.

Step 6: Hope This Was Helpfull!

Hope this was helpful and if you need any help or have any questions/concerns please pm me or post a comment.

If you want to learn more about how this script works, please pm me and I'll explain it the best I can.

Also, if you do not feel like creating the file yourself, I have made one were each time you run the .vbs you set your own password such as in the picture above.