Windows: Lock the screen by command line

Hi,

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

Michael

Advertisment to support michlstechblog.info

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

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

Time limit is exhausted. Please reload CAPTCHA.