How to Lock Your Windows 10 PC Using Command Prompt

Windows 10 logo

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.

Open Command Prompt from Windows Search

The Command Prompt will now open. Here, run this command to lock your Windows 10 PC.

Rundll32.exe user32.dll, LockWorkStation

Command to lock your Windows 10 PC

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.

Open the command prompt as administrator

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

command to set the lock screen timeout

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

Final command to set the lock screen timer

Now your locked screen will expire after the set amount of time. Try!

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.