Cyprich.com

Occasionally Relevant Insights from a Software Builder

By

How to Lock a Windows 10 Screen from a Console Command

I normally lock my computer when I step away from it to prevent other users from getting access to it which would give them full access to my web sites, databases, and other sensitive files. I do this as opposed to logging out of the computer. Locking the screen keeps you logged in but it requires you to enter your login password to open the desktop.

While working on a computer, you can press the Windows + L keys to lock the screen. If your logged in by VNC, closing your connection does not automatically lock your computer and it will remain in an unlocked state so that anyone can start using it. A simple way to lock your computer from a command prompt is to run:

rundll32.exe user32.dll,LockWorkStation

Opening a command prompt to do this is too much work, so create a batch file (Lock Workstation.bat), place that line in it, and keep the file on the Desktop for easy access. Then when you complete your remote session, lock the screen before you close the connection. 

Leave a Reply

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