Lock Your Workstation from the Command Line (rundll32)

The classic user32.dll,LockWorkStation rundll32 trick locks Windows instantly — no GUI needed.

WindowslocksessioncliLow risk
Run rundll32.exe user32.dll,LockWorkStation to lock the current session immediately.

01Command

Command
$ rundll32.exe user32.dll,LockWorkStation

02What it does

This calls the Win32 LockWorkStation API, the same one Win+L triggers, so the session is secured with your normal sign-in method. It is ideal for shortcuts, scheduled tasks (auto-lock after idle without a screen saver), or the end of a script that performed admin work. Note rundll32 is only meant for this small set of hand-written entry points — LockWorkStation is one of the legitimate ones.

03Risk

RiskLow risk

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • Rundll32 - Run a DLL command
    SS64 · technical · 2026-09-17
    Evidence: Documents the rundll32 user32.dll,LockWorkStation entry point for locking the workstation from a command line or shortcut.
  • LockWorkStation function (winuser.h)
    Microsoft Learn · vendor-doc · 2026-09-17
    Evidence: Documents the LockWorkStation API that rundll32 invokes: it locks the workstation's display, requiring the caller to unlock normally.

Last verified: 2026-09-17 · Category: Security & Privacy