Windows: Lock the screen by command line


there is no command line tool that can lock the screen, but it’s possible by calling the Win32 API function.
This can be done by Rundll32.exe

D:\> Rundll32.exe user32.dll,LockWorkStation


One thought on “Windows: Lock the screen by command line”

  1. FYI – Also if you want to run screen saver then lock screen via a one line cmd line. Good for using for shortcut key scripts.

    start /wait %windir%\SCREENAVER.scr & rundll32.exe user32.dll,LockWorkStation

Leave a Reply