How to create a Windows shortcut to lock the screen

How many times have you been thinking “all my programmer friends are here and I really need to go to the bath room but what if they see my lame code!?”.
And you really wish you could remember the command to lock the screen in Windows? It happens all the time, right?

You don’t have to worry anymore. With this simple shortcut you just need to double click it, or just click it once depending on where you put it and Windows will lock the screen instantly.
You can put the shortcut to lock the screen in you taskbar, startmenu, desktop…

And then when you’re back at your PC again, you just have to type your password to get back into the session right where you left off.
Here’s what’s working for Windows 10, it will probably work for earlier versions of Windows too.

How to create the lock screen shortcut
1: Right click on your Windows desktop to bring up the menu.

2: Hover over “New” and click on “Shortcut”.

3: If you have Windows installed under “C:\Windows” like most people do, just copy and paste the following line into the text field “Type the location of the item”.

C:\Windows\System32\rundll32.exe user32.dll,LockWorkStation

Press, “enter” or click the “Next” button and choose the coolest name you can think of for your new shortcut!
That’s pretty much it.

Well, I forgot one really important part. You can also choose icon for the otherwise ugly shortcut. Right-click on it and go to “Properties”. Under the “Shortcut” tab you’ll see a button that allow you to change the icon. You can download a ico-file from the Internet or use ones already on your system.

Bonus Tip: Lock the Windows screen with your keyboard

And here’s a little bonus tip that’s really handy. You can lock your screen within 1 second by pressing CTRL + ALT + DEL and then enter. So, after all you don’t really need a shortcut.