How to lock Windows screen on startup?

6,025

Solution 1

Try

RUNDLL32 USER32.DLL,LockWorkStation

http://www.robvanderwoude.com/rundll.php

You can create a Shortcut to the c:\Windows\System32\rundll32.exe and add the parameter. If you put this shortcut in the Autostart folder, your computer will be locked after login.

Screenshot is german, but the shortcut target should look like this, (verified with Windows 8 but should work with Windows 2000+)

shortcut

Solution 2

If I am not mistaken, when you disable auto login the lock screen will be automatically activated.

Share:
6,025
Rodrigo Jimenez
Author by

Rodrigo Jimenez

Soluto #SOreadytohelp

Updated on September 18, 2022

Comments

  • Rodrigo Jimenez
    Rodrigo Jimenez almost 2 years

    I like to go get coffee while the computer starts. However we have a policy that says the screen must be locked when away.

    How can I make sure that the screen locks immediately after logging in?

  • Jürgen Steinblock
    Jürgen Steinblock almost 11 years
    But that will prevent the "preloading" of apps that are run at first login (mail client, browser)
  • matan129
    matan129 almost 11 years
    Right. I have another idea in mind, I will think about it
  • matan129
    matan129 almost 11 years
    Well I thought about launching the executable in system32 which locks the computer, and apparently it's rundll32 - and SchlaWiener gave you great answer.
  • deed02392
    deed02392 almost 11 years
    +1, I used to use this to lock my XP workstation from RDP sessions.
  • user
    user almost 11 years
    -1. Raymond Chen/The Old New Thing: What can go wrong when you mismatch the calling convention?: "[The function signature required for functions called by rundll32.exe is documented in this Knowledge Base article.] That hasn't stopped people from using rundll32 to call random functions that weren't designed to be called by rundll32, like [user32 LockWorkStation] or [user32 ExitWindowsEx]." Besides, rundll32 is deprecated since Vista.
  • Jürgen Steinblock
    Jürgen Steinblock almost 11 years
    @Michael, didn't know about that, thanks. Raymond has a good point and here are some more reasons why not to use rundll blogs.msdn.com/b/oldnewthing/archive/2013/01/04/10382242.asp‌​x and as a programmer it makes sense to say Don't use it, call the function yourself but as a user it should be more like Use it at your own risk, if it works for you
  • user
    user almost 11 years
    @SchlaWiener I might agree, if it wasn't for the fact that as pointed out by Raymond Chen this kind of trick can work intermittently. Working as a programmer, intermittently occuring bugs are the ones I loathe the most trying to track down. And I don't want to think about what calling (random) Win32 API functions with random parameters could potentially do to application state. If I feel like it later today or this weekend, maybe I'll put together a small application that simply calls LockWorkStation as it was intended to be called, and put it somewhere for everyone's benefit.
  • Rodrigo Jimenez
    Rodrigo Jimenez almost 11 years
    seems to work for me!