Is there a way to turn off the display in Windows (7), preferably without using additional software?

Powershell script works fine, but leaves command-line window after turning on the display.

  • 2
    You have an existing ps1 script? They don't usually leave the window open after running. Perhaps there's something in the script that needs to be changed to let the window close? Commented Aug 10, 2011 at 13:16
  • 1
    How about using the blank screen saver plus setting your power settings to turn off the monitor after some period of non-use?
    – uSlackr
    Commented Aug 10, 2011 at 13:47
  • 6
    also if you may paste the ps script here - it will be useful for us visitors Commented Oct 10, 2012 at 19:27
  • 1
    Put PowerShell command from below answers in a file, save as .ps1, chose default app to open with as powershell, create a shortcut for it, go to the properties of the shortcut and set up a key combination to trigger it. this key combination will work from anywere. Commented Jul 11, 2021 at 0:51
  • might have to place the shortcut in C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories for the shortcut keystore to work. Commented Jul 11, 2021 at 1:00

6 Answers 6


A couple more options:

  • Turn Off LCD - just place the executable on your desktop
  • NirCmd - you'll need to copy nircmd.exe to your Windows system directory, or add its location to the PATH environment variable. Then just run nircmd monitor off from the command line. More information at the link.
  • 17
    +1 for nircmd. Imho tools set from Nir Sofer and Russinovich should be installed on any advanced user's PC. Commented Apr 20, 2015 at 20:11
  • I have tools from Russinovich but this is the first time I've heart of Nir Sofer. Looks cool
    – Luigi
    Commented Nov 5, 2016 at 13:14
  • nircmd and Turn off LCD will somehow turn back screen on after exactly 5mins on Windows 10.
    – Cerlancism
    Commented Aug 16, 2020 at 20:26
  • 2
    For nircmd, I had to use nircmd monitor async_off or it wouldn't exit after turning the monitor off. Commented Sep 24, 2022 at 17:01

On a laptop you can use the keyboard shortcut combination of Fn+F7 (F7 might differ depending on the laptop model) and for a desktop you can always use the power button.

Do you need any other specifications such as wake up on mouse movement or something else?

You can always create a shortcut and assign a keyboard shortcut to a black screensaver, use this path:

%systemroot%\system32\scrnsave.scr /s

This will not turn off you screen but make it completely black

  • 2
    I have desktop and as far as I know it is not possible to set power button to turn off display. Wake up on mouse movement or keyboard key is fine. Black screensaver leaves glow, which is visible at night.
    – unicoio
    Commented Aug 10, 2011 at 12:21
  • 3
    @unicoio If it's to turn off the screen for the whole night why don't you use the power button on the screen itself?
    – Greg
    Commented Aug 10, 2011 at 13:04
  • 1
    I arrived at this question over three whole steps, literal strides. Your screensaver answer was exactly what I needed. My LCD TV treats solid complete black as off.
    – Motomotes
    Commented Mar 26, 2014 at 2:57
  • 2
    What's /s for, it works without the switch as well.
    – user373230
    Commented Oct 2, 2016 at 23:29
  • 5
    In Windows 10, screen gets black when scrnsave.scr is entered in the search box or in run dialog, but it requires /s when executed from cmd.exe (without it, a dialog pops up informing that this screensaver has no configurable options).
    – Palec
    Commented Jun 8, 2017 at 1:22

You can use WinAPI call SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2) where HWND_BROADCAST = 0xFFFF, WM_SYSCOMMAND = 0x0112 and SC_MONITORPOWER = 0xF170. The 2 means the display is being shut off.

There are several ways to make the call:

  • Separate executable. You can fire it through a script, command line, Run window, shortcut (*.lnk), etc. Note that shortcuts can be invoked using a keyboard shortcut. The executable may be written in C or C++, or via P/Invoke in .NET languages (C# or PowerShell), or in many other languages that have a foreign language interface (e.g. JNI in Java).

  • AutoHotkey script. For a non-programmer, this way is probably simpler. Making customizations still requires some scripting. This script turns monitor off on Win + M:

    Sleep 1000
    SendMessage, 0x112, 0xF170, 2,, Program Manager

Note the timeout before the SendMessage call in the AutoHotkey script. It gives the user a chance to release keys (in case their release would wake up the monitor again). Do not forget about it even when making the call from a script in another language.

For more info, see the documentation of SendMessage function, WM_SYSCOMMAND message and AutoHotkey SendMessage. It might be of interest that since Windows 8, using the same method to turn monitor on does not work, but there is a work-around.

  • For the AutoHotkey method, I would recommend using a Sleep 50 after SendMessage instead of this long sleep before. This has the effect of turning off the screen immediately. Tested on my own laptop and found it to be better.
    – cyqsimon
    Commented Aug 17, 2020 at 18:25

Powershell one-liner would be:

(Add-Type -MemberDefinition "[DllImport(""user32.dll"")]`npublic static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);" -Name "Win32SendMessage" -Namespace Win32Functions -PassThru)::SendMessage(0xffff, 0x0112, 0xF170, 2)
  • 4
    This was close, but didn't work for me (Win10). However I put this into a .bat file and it worked: powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::SendMessage(-1,0x0112,0xF170,2)
    – Kidquick
    Commented Dec 15, 2020 at 3:04
  • 1
    Well adapted! I'm a PowerShell user and would run from a .ps1-file. Running unsigned PowerShell-scripts isn't enabled by default, so your solution will work for all. Commented Dec 15, 2020 at 10:05
  • 2
    This does not work on my Windows 10 20H2 computer. The one-liner will hibernate the entire computer. Same problem with NirCMD. The one-liner and NirCMD work on Windows 7 computer.
    – JPX
    Commented Jan 13, 2021 at 15:26
  • 1
    I tested the single-liner and NirCMD in two Lenovo ThinkCentre M90N-1 computers which will hibernate. Windows turns off the monitor without hibernation. If I try to turn the display on by running a command nircmd monitor on, monitor will turn on for a second and then the computer will hibernate.
    – JPX
    Commented Jan 13, 2021 at 19:33
  • 2
    I've tested the PowerShell single-liner on couple of my computers. Working as as expected. Given you're the first one to report computer hibernation, I'd have to assume this is a Lenovo-issue. Commented Jan 14, 2021 at 7:02

As one-liner for instance using Win+R:

powershell -command $obj = Add-Type -MemberDefinition '[DllImport(""""user32.dll"""")] public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name fn -Namespace ns -PassThru; $obj::SendMessage(0xffff, 0x0112, 0xF170, 2)

It's not possible to put in a shortcut .lnk file unfortunately because the line is too long, I run it with Flow Launcher and my Favorites Plugin, this supports long command lines.


  • 5
    i can create a shortcut with this command without any problem: powershell (Add-Type '[DllImport(\"user32.dll\")]public static extern int PostMessage(int h,int m,int w,int l);' -Name a -Pas)::PostMessage(-1,0x0112,0xF170,2) check this Commented Feb 22, 2023 at 20:21

Based on Ujjwal Singh's answer, here is a Python script to do so.

First install pywin32 module, if you haven't already.

$ python -m pip install pywin32

Here is the script:

from win32api import SendMessage

    # https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendmessage?redirectedfrom=MSDN#parameters
    # https://docs.microsoft.com/en-us/windows/win32/menurc/wm-syscommand
    0x0112,  # WM_SYSCOMMAND
    0xF170,  # SC_MONITORPOWER
    2,  # the display is being shut off

Or if you prefer a one-liner to run directly from command prompt:

$ python -c "import win32api; win32api.SendMessage(0xFFFF, 0x0112, 0xF170, 2)"
  • How can I modify this Python script to specify a specific individual monitor, in a multi-monitor configuration? Thanks! :)
    – pete_NZ
    Commented Nov 29, 2023 at 2:58
  • (Also asked here: stackoverflow.com/questions/74130702/… ) ... but I'm not experienced enough to act on the advice)
    – pete_NZ
    Commented Nov 29, 2023 at 3:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .