Locking Windows with VBScript

I’ve decided to make my various Windows installs boot up, automatically log in, then lock themselves. This is because I have tired of turning my PC on, waiting for it to boot up, then logging in and waiting about the same amount of time for the login process to go through.

A simple script to lock a Windows install – throw this into a .vbs file and double click it and you’re done:


Set shell = WScript.CreateObject("WScript.Shell")
shell.Run "rundll32.exe user32.dll,LockWorkStation",1,false

3 thoughts on “Locking Windows with VBScript”

  1. Neat.
    I’m assuming you then plaves the VBScript into the startup?
    Have you had any issues of programs not loading once the lock is in place?

    Unfortunately it won’t work here at school as we have roaming profiles. You won’t be able to set an initial account because you don’t know who will be sitting down on the PC. Might be more useful at home.

  2. Yep, just drop the script into the startup folder. You might want to also drop the line:

    Wscript.Sleep 10000

    (where the number is the number of milliseconds to sleep for), just in case there’s any issues locking the box immediately on startup (I can’t imagine any).

    I only set this up at home last night so I’ll let you know how it goes when I turn my PC on when I get home!

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.