How to lock Windows 10 and turn off the display with one click

In Windows 10, you can lock your current session for security reasons using the Win + L shortcut. If you have not changed the default power management settings, the display will be turned off after 10 minutes. Windows does not provide a native way to turn off display directly on demand by running a command or pressing some button. If you are leaving your PC for a long time, you might want to lock your PC and turn off the monitor instantly with one click.

Before you continue, you might want to read about unlocking the hidden display off timeout for the Lock screen in Windows 10. This will allow you to reduce the period when your display turns off after locking. But still it doesn't provide a way to simultaneously lock your PC and turn off the monitor instantly.

It can be done via a simple script.

To make it working, we need to use the freeware tool, Nirsoft Nircmd, which allows you to control various OS parameters and features from the command line.

Download NirCmd from here

Now, create a new *.VBS file as follows.

  1. Press the Win + R shortcut keys together on the keyboard to bring up the Run dialog, and then type notepad into the Run box.windows-10-run-notepad
    Tip: see our ultimate list of all Windows keyboard shortcuts with Win keys.
  2. Copy and paste the following text into Notepad:
    'Lock PC and Turn off Display
    
    '*************************
    
    ' Created by Winaero
    
    ' https://winaero.com
    
    Dim WSHShell
    
    Set WSHShell=WScript.CreateObject("WScript.Shell")
    
    WSHShell.Run "Rundll32.exe user32.dll,LockWorkStation", 0
    
    WSHShell.Run "nircmd.exe monitor async_off", 0

    windows-10-notepad-with-script

  3. In Notepad, click File menu -> Save item. The "Save as" dialog will appear. Browse for the desired folder where you wish to store the script and type "lock.vbs" with quotes in the File Name text box (the double quotes are required so that the file gets directly saved as "lock.vbs" and not "lock.vbs.txt"):
    notepad-save-file
  4. Put nircmd.exe you downloaded earlier in the same folder. You can also copy the NirCmd.exe into your C:\Windows directory. This is important so that all scripts can easily find its EXE file.windows-10-ready-script

That's all. You are done.

Now double click the "lock.vbs" file. You Windows 10 PC will be locked and the screen will be turned off. You can use this trick in previous Windows version too.

Tip: you can pin the "lock.vbs" file to the Start menu in Windows 10. See the following article: How to pin any file to Start Menu in Windows 10.

5 thoughts on “How to lock Windows 10 and turn off the display with one click

  1. Viktor Rucký

    It’d be cool to see a way to lock and display the screensaver, I love looking at my screensavers. Downloaded the old 3D pipes .scr file, one of my favourites. :)

    Reply
  2. pd

    I could desperately use the opposite of this because Intel’s graphics drivers, Windows 10 and HP hardware are unable to consistently wake up and initiliaze monitors after locking thru Win + L. I’ve tried everything from firmware updates to the dock to running the monitors in DisplayPort daisy-chain mode. Nothing works!

    It should not be that hard for these giants of IT to get this right. it’s a disgrace.

    Reply
  3. Kramar

    Turn_Off_Monitor_and_Lock_Computer.bat containing

    @echo off
    start “” nircmd.exe lockws
    start “” nircmd.exe monitor off

    will also work

    Reply
    1. Sergey Tkachenko Post author

      Great, thanks for sharing!

      Reply
  4. Kizuna

    So, this only partly works for me. It does what it says, but about a second or two later immediately wakes the screen, which defeats the purpose for me; I want it to lock and turn off the display at night before I sleep.

    Reply

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.