Lock Your Screen from a BAT File

Locking your screen while you are away can be very important, especially in a work environment. But sometimes it would be nice if there was a little program that could lock your screen for you, or if there was a handy little icon on your desktop for you to double click to lock your screen. With just this simple little BAT file you can create a quick program that can do just that. Open up Notepad and put in the following, then save it as screenlock.bat.

@echo off
rundll32.exe user32.dll, LockWorkStation

Once you have the screenlock.bat file created, you can right click on it, and Create a Shortcut to put on your desktop.  Then all you have to do is double click it and your screen will be locked when you get up to walk away.  If you want to have some fun, set this on a friend’s computer and set it to run every few minutes as a scheduled task in the Task Scheduler.

Now I know there are other, even arguably, easier ways to lock your screen.  Such as hitting Windows+L, or setting a screen saver and requiring a password when it ends.  But neither of those is as fun or geeky as making your own.