
One of the first rules of cybersecurity is to always lock your PC before you walk away. While this might not be the fastest way to lock your Windows 10 PC, you can do so using the Command Prompt.
Lock your Windows 10 PC using the Command Prompt
First, open command prompt on your PC by opening the “Start” menu, typing “cmd” into the Windows search bar, and then selecting “Command Prompt” from the search results.
The Command Prompt will now open. Here, run this command to lock your Windows 10 PC.
Rundll32.exe user32.dll, LockWorkStation
Once executed, your PC will be locked. You will need to log back in with your PIN, password, or your usual login method.
RELATED: How to lock your Windows 10 PC remotely
Set the lock screen timeout setting using the command prompt
After you’ve locked your PC, the lock screen usually displays for a while before it expires. You can set the time that must pass before the expiration using the command prompt.
To do this you will need open command prompt as administrator. Do this by typing “cmd” into the Windows search bar and then right-clicking “Command Prompt” in the results. Then select “Run as administrator” from the menu that appears.
With the command prompt open, run this command.
powercfg.exe / SETACVALUEINDEX SCHEME_CURRENT SUB_VIDEO VIDEOCONLOCK
Replace with the desired duration in seconds. This means that if you want to expire the lock screen after two minutes, you have to enter this command:
powercfg.exe / SETACVALUEINDEX SCHEME_CURRENT SUB_VIDEO VIDEOCONLOCK 120
Note: This command sets the timeout setting for your PC’s lock screen if it is plugged into a power source. To set your PC’s lock screen timeout setting if it is running on battery power, replace / SETACVALUEINDEX with / SETDCVALUEINDEX and run the command as normal.
Then run this command:
powercfg.exe / SETACTIVE SCHEME_CURRENT
Now your locked screen will expire after the set amount of time. Try!