VBScript Screen Lock


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, P...

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, here is one. There is also vbsedit which I use.

Step 1: My Script...

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

Windows XP to 7------->LINK, Windows 8 and up------->LINK

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)


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. You can download it here: LINK



  • Creative Misuse Contest

    Creative Misuse Contest
  • Water Contest

    Water Contest
  • Oil Contest

    Oil Contest

10 Discussions

NOTE: If you ever forget your password for this program and you added the program to the startup, restart windows and press F8 on restart to boot into safe mode. Then go into the start menu and delete the file in the startup folder, then restart the computer and boot back into windows normally. Then to re-enable the ctrl-alt-delete options, reset your password in the script, then compile it, and run it again. Enter your password and then all the options will be re-enabled.

1 reply

what is the default password, i launched it and i cant get to my desktop

I just updated a little GUI version I made using hta. This one just like my previous GUI one, masks the password input, but this one also disables alt-f4, etc. If you want the source code, just ask.


I just fixed the "black screen bug". Turns out my code had to be:

Objshell.run "cmd /c explorer.exe" instead of

Objshell.run "explorer.exe"

I think your computer launched the wrong explorer.exe:

To fix press ctrl-alt-del and open task manager, then go to file--->new task and type "explorer.exe". Press ok.

You were supposed to set the password in the file, but if you did not change it then the password is:

win xp to win 7:

----------YOUR PASSWORD HERE----------

or for win8+:

---------------YOUR PASSWORD HERE---------------

and uhhh i just went to my other computer redownloaded it, got the password, but the black screen still stays for me

what is the default password, i launched it and i cant get to my desktop

Just updated all the files, the screen lock is now even faster and no longer creates temporary files.