How to lock your Windows PC 10 via command prompt

Contents

Windows logo 10

One of the first rules of cyber security is to always lock your PC before walking away. Although it may not be the fastest way to lock down your Windows PC 10, you can do it using command prompt.

Lock your Windows PC 10 via command prompt

First, open the command prompt on your PC by opening the menu “Beginning”, writing “cmd” in the Windows search bar and then selecting “Symbol of the system” in search results.

Open command prompt from Windows search

The command prompt will open. Here, run this command to lock your Windows PC 10.

Rundll32.exe user32.dll,LockWorkStation

Command to lock your Windows PC 10

Once executed, your pc will crash. You will need to sign in again with your PIN, password or any login method you use regularly.

RELATED: How to lock your Windows PC 10 remote form

Determine lock screen timeout settings via command prompt

Once you have locked down your PC, the lockscreen will generally be displayed for a certain period of time before it times out. You can determine the amount of time that must elapse before the time expires through the command prompt.

To do this, you will need to open command prompt as administrator. To do it, scribe “cmd” in the Windows search bar, and then right-click “Symbol of the system” in the results. Next, select “Execute as an administrator” in the menu that appears.

Open command prompt as administrator

With the command prompt open, run this command.

powercfg.exe /SETACVALUEINDEX SCHEME_CURRENT SUB_VIDEO VIDEOCONLOCK <time>

Replace <time> with the desired amount of time in seconds. That means if you want the lock screen to time out after two minutes, you must enter this command:

powercfg.exe /SETACVALUEINDEX SCHEME_CURRENT SUB_VIDEO VIDEOCONLOCK 120

command to set lock screen timeout timer

Note: This command sets the lock screen timeout setting for your PC if it is connected to a power source. To set the lock screen timeout for your PC if it is running on battery power, change/SETACVALUEINDEX for/SETDCVALUEINDEX and run the command regularly.

Next, run this command:

powercfg.exe /SETACTIVE SCHEME_CURRENT

Final command to set lock screen timer

Now the lock screen will expire after the set amount of time. Give it a chance!

Subscribe to our Newsletter

We will not send you SPAM mail. We hate it as much as you.