How to lock Windows PC after automatic login

How to lock Windows PC after automatic login

On Windows, automatic log-in is handy because you can launch the PC program when it starts. You can even let your PC boot automatically at specific times. To improve security, you can let Windows 10 automatically lock and ask for a password after you sign in automatically.

How to lock Windows PC after automatic login

With auto-lock at sign-in, your PC will automatically log in, launch and start the program on boot – but it’ll lock itself and you’ll have to enter your password to use it. This is not as secure as avoiding automatic sign-in, as your user account password will still be saved and entered automatically by the system, but it’s better than having your PC start up automatically and provide an unrestricted desktop.

To do this, all you have to do is let Windows run the command after it’s logged in:

rundll32.exe user32.dll, LockWorkStation

This command will lock the system. It completes the same function as pressing Windows + L. There are several ways to get Windows to run it when logged in, including in Group Policy. The easiest way, though, is to simply add a key shortcut to your Startup folder.

I did this on Windows 10, but it should work on older versions of Windows as well, including Windows 8 and Windows 7.

Create key shortcuts

First, open the Startup folder. To do so, press Windows + R to open a Run dialog box, type the following line and press Enter :

shell:startup

In the Startup folder, right-click and choose New> Shortcut .

Create a new shortcut

In the Create Shortcut dialog box, copy and paste (or type) the following command:

rundll32.exe user32.dll, LockWorkStation

Click Next to continue.

Click Next to continue

Name the shortcut whatever you like – for example, ” Lock Computer “.

Name the shortcut

All operations are completed!

If you double-click the created shortcut, Windows will lock your computer. You will then have to sign in with your password, PIN or any other login method you use.

When you log in to your PC, Windows launches this shortcut along with other startup programs and automatically locks your PC. After you unlock it, you should be able to do everything on the machine as you normally would.

To undo the change, just reopen the shell: startup folder and delete the Lock Computer shortcut you created.