Personalization Add "Turn off display" Context Menu in Windows 11


Display_banner.png

This tutorial will show you how to add a Turn off display desktop context menu that will let users Turn off display or Lock computer and Turn off display on demand in Windows 10 and Windows 11.

By default, You can specify a screen timeout for how long the PC sits inactive without user activity before all connected displays automatically turn off.

When your display turns off, you would just need to move the mouse, touch the touchpad or touchscreen, click a mouse or touchpad button, or press a key for the display(s) to turn back on.

There may be times when you would like to turn off the display or lock computer and turn off display on demand instead.


While you must be signed in as an administrator to add or remove the "Turn off display" context menu, all users will be able to use the context menu.




Contents

  • Option One: Add "Turn off display" to Desktop Context Menu
  • Option Two: Remove "Turn off display" from Desktop Context Menu


EXAMPLE: "Turn off display" desktop context menu

It is required to click/tap on Show more options first by default, then click/tap on Turn off display.


Show_more_options.png
Turn_off_display_context_menu.png





Option One

Add "Turn off display" to Desktop Context Menu


1 Click/tap on the Download button below to download the REG file below.

Add_Turn_off_display_to_desktop_context_menu.reg


(Contents of REG file for reference)
Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\TurnOffDisplay]
"Icon"="imageres.dll,-109"
"MUIVerb"="Turn off display"
"Position"="Bottom"
"SubCommands"=""

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\TurnOffDisplay\shell]

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\TurnOffDisplay\shell\01menu]
"Icon"="powercpl.dll,-513"
"MUIVerb"="Turn off display"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\TurnOffDisplay\shell\01menu\command]
@="powershell.exe -NoProfile -ExecutionPolicy Bypass -Command \"Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public static class User32 { [DllImport(\\\"user32.dll\\\", SetLastError = true)] public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam); }' -ReferencedAssemblies System.Windows.Forms; Start-Sleep -Seconds 2; $null = [User32]::SendMessage((New-Object System.Windows.Forms.Form).Handle.ToInt32(), 0x0112, 0xF170, 2);\""


[HKEY_CLASSES_ROOT\DesktopBackground\Shell\TurnOffDisplay\shell\02menu]
"MUIVerb"="Lock computer and Turn off display"
"CommandFlags"=dword:00000020
"Icon"="imageres.dll,-59"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\TurnOffDisplay\shell\02menu\command]
@="cmd /c \"powershell.exe -Command \"(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)\" & rundll32.exe user32.dll, LockWorkStation\""

2 Save the .reg file to your desktop.

3 Double click/tap on the downloaded .reg file to merge it.

4 When prompted, click/tap on Run, Yes (UAC), Yes, and OK to approve the merge.

5 You can now delete the downloaded .reg file if you like.




Option Two

Remove "Turn off display" from Desktop Context Menu


1 Click/tap on the Download button below to download the REG file below.

Remove_Turn_off_display_from_desktop_context_menu.reg


(Contents of REG file for reference)
Code:
Windows Registry Editor Version 5.00

[-HKEY_CLASSES_ROOT\DesktopBackground\Shell\TurnOffDisplay]

2 Save the .reg file to your desktop.

3 Double click/tap on the downloaded .reg file to merge it.

4 When prompted, click/tap on Run, Yes (UAC), Yes, and OK to approve the merge.

5 You can now delete the downloaded .reg file if you like.


That's it,
Shawn Brink


 

Attachments

Last edited:
Wake Up Problem:

Thank you. This works perfectly even on multiple monitors, as does freeware Monitor Off Utility and Turn Off the Monitor, and others I tried.

However, the problem with my new Win 11 computer (which was not a problem on my Win 10 computer) is that the multi monitors wake themselves up very quickly after being shut down on command.

Using Monitor Off Utility and Turn Off the Monitor apps, the multi monitors wake up immediately (no mouse movement involved). Your context menu command is unique in that it apparently keeps shutting down the waking up monitors only to have them wake up again, and finally your command times out and the monitors totally wake back up after about 20 seconds.

Also, the blue power lights on the monitors never shut off (and the mouse cursor moves around on some of the screens), so doesn't this meant the monitors never completely shut off?

Seems like the laptop screen and primary external monitor are the hardest to keep from waking up, compared to the 2 other externals, although the blue power lights stay on with all of them and all of them glow visible at night with the monitors being gray rather than black and obviously still on, and the primary external will show the Widows welcome screen all night after being woken right after they are shut down by your command.

Any suggestions how to disable this monitor wake up? I asked AI and was suggested to look in Event Viewer to see what is waking the monitors, or perhaps stopping them from completely turning off. But it did not give sufficient guidance that a non-tech like me could work through this.

Also suggested I disable the wake timers settings in Control Panel advanced power settings which I did to no avail.

Any help is much appreciated. Strange that the freeware worked fine without any intervention in Win 10 not Win 11, even though all the programs and devices are virtually the same.

Thank you.
 

My Computer

System One

  • OS
    windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Dell 3530
Wake Up Problem:

Thank you. This works perfectly even on multiple monitors, as does freeware Monitor Off Utility and Turn Off the Monitor, and others I tried.

However, the problem with my new Win 11 computer (which was not a problem on my Win 10 computer) is that the multi monitors wake themselves up very quickly after being shut down on command.

Using Monitor Off Utility and Turn Off the Monitor apps, the multi monitors wake up immediately (no mouse movement involved). Your context menu command is unique in that it apparently keeps shutting down the waking up monitors only to have them wake up again, and finally your command times out and the monitors totally wake back up after about 20 seconds.

Also, the blue power lights on the monitors never shut off (and the mouse cursor moves around on some of the screens), so doesn't this meant the monitors never completely shut off?

Seems like the laptop screen and primary external monitor are the hardest to keep from waking up, compared to the 2 other externals, although the blue power lights stay on with all of them and all of them glow visible at night with the monitors being gray rather than black and obviously still on, and the primary external will show the Widows welcome screen all night after being woken right after they are shut down by your command.

Any suggestions how to disable this monitor wake up? I asked AI and was suggested to look in Event Viewer to see what is waking the monitors, or perhaps stopping them from completely turning off. But it did not give sufficient guidance that a non-tech like me could work through this.

Also suggested I disable the wake timers settings in Control Panel advanced power settings which I did to no avail.

Any help is much appreciated. Strange that the freeware worked fine without any intervention in Win 10 not Win 11, even though all the programs and devices are virtually the same.

Thank you.

Hello p999, and welcome. :alien:

This will only turn off the display by putting the display to sleep, it will not actually power off the monitors. It'll be normal to still see the power light on for the monitors.

Usually, it's any type of user activity that can cause the display to wake up.

As a test, how does the BAT file in the post below work for you?

 

My Computers

System One System Two

  • OS
    Windows 11 Pro for Workstations
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom self build
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING (11GB GDDR5X)
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G75 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3 wall mounted
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gbps Download and 35 Mbps Upload
    Browser
    Google Chrome
    Antivirus
    Microsoft Defender and Malwarebytes Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    CyberPower CP1500PFCLCD
    Galaxy S23 Plus phone
  • Operating System
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    Surface Laptop 7 Copilot+ PC
    CPU
    Snapdragon X Elite (12 core) 3.42 GHz
    Memory
    16 GB LPDDR5x-7467 MHz
    Monitor(s) Displays
    15" HDR
    Screen Resolution
    2496 x 1664
    Hard Drives
    1 TB SSD
    Internet Speed
    Wi-Fi 7 and Bluetooth 5.4
    Browser
    Chrome and Edge
    Antivirus
    Windows Defender
Hello p999, and welcome. :alien:

This will only turn off the display by putting the display to sleep, it will not actually power off the monitors. It'll be normal to still see the power light on for the monitors.

Usually, it's any type of user activity that can cause the display to wake up.

As a test, how does the BAT file in the post below work for you?

Thanks for the welcome Brink. Your forum is really really great. My first time here, but used to benefit from and post to TenForum.

Sorry to say that I don't know how to run a BAT. I don't think I've done that since DOS, if then, and don't remember. Could you please give directions.

Do I run this BAT after I downloaded and ran the original file from the Original Poster?

Also, I guess that even if the 2 second delay in the BAT works, which hopefully it will, the monitors won't power off only go to sleep and continue with their soft glow all night? I don't want to shut down computer only shut down the multi monitors.

Again, strange since this was not the case with Win 10, where the freeware shut them down completely with no power lights.

Many thanks in advance.
 

My Computer

System One

  • OS
    windows 11
    Computer type
    Laptop
    Manufacturer/Model
    Dell 3530
Thanks for the welcome Brink. Your forum is really really great. My first time here, but used to benefit from and post to TenForum.

Sorry to say that I don't know how to run a BAT. I don't think I've done that since DOS, if then, and don't remember. Could you please give directions.

Do I run this BAT after I downloaded and ran the original file from the Original Poster?

Also, I guess that even if the 2 second delay in the BAT works, which hopefully it will, the monitors won't power off only go to sleep and continue with their soft glow all night? I don't want to shut down computer only shut down the multi monitors.

Again, strange since this was not the case with Win 10, where the freeware shut them down completely with no power lights.

Many thanks in advance.
No worries. You'll just need to copy the code into Notepad, save it with a ,bat extension, then run the .bat file.
 

My Computers

System One System Two

  • OS
    Windows 11 Pro for Workstations
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom self build
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING (11GB GDDR5X)
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G75 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3 wall mounted
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gbps Download and 35 Mbps Upload
    Browser
    Google Chrome
    Antivirus
    Microsoft Defender and Malwarebytes Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    CyberPower CP1500PFCLCD
    Galaxy S23 Plus phone
  • Operating System
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    Surface Laptop 7 Copilot+ PC
    CPU
    Snapdragon X Elite (12 core) 3.42 GHz
    Memory
    16 GB LPDDR5x-7467 MHz
    Monitor(s) Displays
    15" HDR
    Screen Resolution
    2496 x 1664
    Hard Drives
    1 TB SSD
    Internet Speed
    Wi-Fi 7 and Bluetooth 5.4
    Browser
    Chrome and Edge
    Antivirus
    Windows Defender
Is there anyway to add a keyboard shortcut to option 1 without having to make a shortcut on the desktop? Like Windows Key + F4 or something like that. Or just make Windows Key + L turn off monitors as well as lock it. Cheers on the reg file though! Very helpful thank you
 

My Computer

System One

  • OS
    Windows 11
    Computer type
    PC/Desktop
Is there anyway to add a keyboard shortcut to option 1 without having to make a shortcut on the desktop? Like Windows Key + F4 or something like that. Or just make Windows Key + L turn off monitors as well as lock it. Cheers on the reg file though! Very helpful thank you
You can install PowerToys and use its Keyboard Manager feature to Remap shortcuts.
 

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming F16 (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Mouse
    Logitech G402
    Keyboard
    Logitech K800
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
How would I use Remap Shortcuts for context menu? I'm confused.
The Remap shortcuts feature also lets you Remap a shortcut to start an app. So, you can make the (App option of the) new shortcut point to powershell.exe and also specify the arguments that will be sent to powershell.exe (i.e. by using the Args option also in addition to the App option).
 

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming F16 (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Mouse
    Logitech G402
    Keyboard
    Logitech K800
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
Using this context menu will leave a command prompt window open that you will need to manually close when you resume.
fixed. this will not leave any consoles open:

Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\Turn Off Display]
"Icon"="%SystemRoot%\\System32\\shell32.dll,25"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\Turn Off Display\Command]
@="cmd /c start /min \"\" powershell -WindowStyle Hidden Add-Type -MemberDefinition '[DllImport(\\\"user32.dll\\\")] public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name 'Win32SendMessage' -Namespace Win32Functions -PassThru; [Win32Functions.Win32SendMessage]::SendMessage(0xffff, 0x0112, 0xF170, 2)\""
 

My Computer

System One

  • OS
    Windows 11 Pro
fixed. this will not leave any consoles open:

Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\Turn Off Display]
"Icon"="%SystemRoot%\\System32\\shell32.dll,25"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\Turn Off Display\Command]
@="cmd /c start /min \"\" powershell -WindowStyle Hidden Add-Type -MemberDefinition '[DllImport(\\\"user32.dll\\\")] public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name 'Win32SendMessage' -Namespace Win32Functions -PassThru; [Win32Functions.Win32SendMessage]::SendMessage(0xffff, 0x0112, 0xF170, 2)\""

Thank you. Tutorial updated. :shawn:
 

My Computers

System One System Two

  • OS
    Windows 11 Pro for Workstations
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom self build
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING (11GB GDDR5X)
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G75 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3 wall mounted
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gbps Download and 35 Mbps Upload
    Browser
    Google Chrome
    Antivirus
    Microsoft Defender and Malwarebytes Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    CyberPower CP1500PFCLCD
    Galaxy S23 Plus phone
  • Operating System
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    Surface Laptop 7 Copilot+ PC
    CPU
    Snapdragon X Elite (12 core) 3.42 GHz
    Memory
    16 GB LPDDR5x-7467 MHz
    Monitor(s) Displays
    15" HDR
    Screen Resolution
    2496 x 1664
    Hard Drives
    1 TB SSD
    Internet Speed
    Wi-Fi 7 and Bluetooth 5.4
    Browser
    Chrome and Edge
    Antivirus
    Windows Defender
Is there anyway to add a keyboard shortcut to option 1 without having to make a shortcut on the desktop? Like Windows Key + F4 or something like that. Or just make Windows Key + L turn off monitors as well as lock it. Cheers on the reg file though! Very helpful thank you
see attached .exe (its zipped). compiled from ahk script. Windows+L will lock pc and turn off displays when this is running (runs in the tray)
 

Attachments

My Computer

System One

  • OS
    Windows 11 Pro
Tutorial updated. :shawn:
Specifying 0xffff as the first parameter of the SendMessage call causes the message to be sent to all top-level windows in the system. I found that doing so can have serious side effects that persist until the computer is restarted. So, I fixed that problem:
Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\Turn Off Display]
"Icon"="%SystemRoot%\\System32\\shell32.dll,25"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\Turn Off Display\Command]
@="\"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -NoProfile -ExecutionPolicy Bypass -Command \"Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public static class User32 { [DllImport(\\\"user32.dll\\\", SetLastError = true)] public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam); }' -ReferencedAssemblies System.Windows.Forms; Start-Sleep -Seconds 2; $null = [User32]::SendMessage((New-Object System.Windows.Forms.Form).Handle.ToInt32(), 0x0112, 0xF170, 2);\""
 

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming F16 (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Mouse
    Logitech G402
    Keyboard
    Logitech K800
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
Specifying 0xffff as the first parameter of the SendMessage call causes the message to be sent to all top-level windows in the system. I found that doing so can have serious side effects that persist until the computer is restarted. So, I fixed that problem:
Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\Turn Off Display]
"Icon"="%SystemRoot%\\System32\\shell32.dll,25"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\Turn Off Display\Command]
@="\"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -NoProfile -ExecutionPolicy Bypass -Command \"Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public static class User32 { [DllImport(\\\"user32.dll\\\", SetLastError = true)] public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam); }' -ReferencedAssemblies System.Windows.Forms; Start-Sleep -Seconds 2; $null = [User32]::SendMessage((New-Object System.Windows.Forms.Form).Handle.ToInt32(), 0x0112, 0xF170, 2);\""

Thank you. Tutorial updated. :shawn:
 

My Computers

System One System Two

  • OS
    Windows 11 Pro for Workstations
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom self build
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING (11GB GDDR5X)
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G75 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3 wall mounted
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gbps Download and 35 Mbps Upload
    Browser
    Google Chrome
    Antivirus
    Microsoft Defender and Malwarebytes Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    CyberPower CP1500PFCLCD
    Galaxy S23 Plus phone
  • Operating System
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    Surface Laptop 7 Copilot+ PC
    CPU
    Snapdragon X Elite (12 core) 3.42 GHz
    Memory
    16 GB LPDDR5x-7467 MHz
    Monitor(s) Displays
    15" HDR
    Screen Resolution
    2496 x 1664
    Hard Drives
    1 TB SSD
    Internet Speed
    Wi-Fi 7 and Bluetooth 5.4
    Browser
    Chrome and Edge
    Antivirus
    Windows Defender
Specifying 0xffff as the first parameter of the SendMessage call causes the message to be sent to all top-level windows in the system. I found that doing so can have serious side effects that persist until the computer is restarted. So, I fixed that problem:
Code:
Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\Turn Off Display]
"Icon"="%SystemRoot%\\System32\\shell32.dll,25"

[HKEY_CLASSES_ROOT\DesktopBackground\Shell\Turn Off Display\Command]
@="\"%SystemRoot%\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\" -NoProfile -ExecutionPolicy Bypass -Command \"Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public static class User32 { [DllImport(\\\"user32.dll\\\", SetLastError = true)] public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam); }' -ReferencedAssemblies System.Windows.Forms; Start-Sleep -Seconds 2; $null = [User32]::SendMessage((New-Object System.Windows.Forms.Form).Handle.ToInt32(), 0x0112, 0xF170, 2);\""
just tested on my desktop with dual monitors. didnt turn either one off. the powershell i posted turns them both off. Can we have a few others test these just so we know before we get tons of comments flooding this tutorial about it not working?
 

My Computer

System One

  • OS
    Windows 11 Pro
just tested on my desktop with dual monitors. didnt turn either one off. the powershell i posted turns them both off. Can we have a few others test these just so we know before we get tons of comments flooding this tutorial about it not working?

I had to modify the command a bit below for it to work.

Code:
@="powershell.exe -NoProfile -ExecutionPolicy Bypass -Command \"Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public static class User32 { [DllImport(\\\"user32.dll\\\", SetLastError = true)] public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam); }' -ReferencedAssemblies System.Windows.Forms; Start-Sleep -Seconds 2; $null = [User32]::SendMessage((New-Object System.Windows.Forms.Form).Handle.ToInt32(), 0x0112, 0xF170, 2);\""
 

My Computers

System One System Two

  • OS
    Windows 11 Pro for Workstations
    Computer type
    PC/Desktop
    Manufacturer/Model
    Custom self build
    CPU
    Intel i7-8700K 5 GHz
    Motherboard
    ASUS ROG Maximus XI Formula Z390
    Memory
    64 GB (4x16GB) G.SKILL TridentZ RGB DDR4 3600 MHz (F4-3600C18D-32GTZR)
    Graphics Card(s)
    ASUS ROG-STRIX-GTX1080TI-O11G-GAMING (11GB GDDR5X)
    Sound Card
    Integrated Digital Audio (S/PDIF)
    Monitor(s) Displays
    2 x Samsung Odyssey G75 27"
    Screen Resolution
    2560x1440
    Hard Drives
    1TB Samsung 990 PRO M.2,
    4TB Samsung 990 PRO M.2,
    8TB WD MyCloudEX2Ultra NAS
    PSU
    Seasonic Prime Titanium 850W
    Case
    Thermaltake Core P3 wall mounted
    Cooling
    Corsair Hydro H115i
    Keyboard
    Logitech wireless K800
    Mouse
    Logitech MX Master 3
    Internet Speed
    1 Gbps Download and 35 Mbps Upload
    Browser
    Google Chrome
    Antivirus
    Microsoft Defender and Malwarebytes Premium
    Other Info
    Logitech Z625 speaker system,
    Logitech BRIO 4K Pro webcam,
    HP Color LaserJet Pro MFP M477fdn,
    CyberPower CP1500PFCLCD
    Galaxy S23 Plus phone
  • Operating System
    Windows 11 Pro
    Computer type
    Laptop
    Manufacturer/Model
    Surface Laptop 7 Copilot+ PC
    CPU
    Snapdragon X Elite (12 core) 3.42 GHz
    Memory
    16 GB LPDDR5x-7467 MHz
    Monitor(s) Displays
    15" HDR
    Screen Resolution
    2496 x 1664
    Hard Drives
    1 TB SSD
    Internet Speed
    Wi-Fi 7 and Bluetooth 5.4
    Browser
    Chrome and Edge
    Antivirus
    Windows Defender
just tested on my desktop with dual monitors. didnt turn either one off. the powershell i posted turns them both off. Can we have a few others test these just so we know before we get tons of comments flooding this tutorial about it not working?
Of course, running additional tests is the only way to go. Specifying the whole "%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" (instead of just powershell.exe) was done because someone in an old thread had reported that PowerShell 5.1 failed to run otherwise if PowerShell Core had been installed on the system. Start-Sleep -Seconds 2 was used to prevent the display from turning immediately back on automatically as a result of mouse movements [that commonly occur when the user lets go of the mouse after the user clicks on the Turn Off Display command].
 

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming F16 (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Mouse
    Logitech G402
    Keyboard
    Logitech K800
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
I had to modify the command a bit below for it to work.

Code:
@="powershell.exe -NoProfile -ExecutionPolicy Bypass -Command \"Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public static class User32 { [DllImport(\\\"user32.dll\\\", SetLastError = true)] public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam); }' -ReferencedAssemblies System.Windows.Forms; Start-Sleep -Seconds 2; $null = [User32]::SendMessage((New-Object System.Windows.Forms.Form).Handle.ToInt32(), 0x0112, 0xF170, 2);\""
I see what I did wrong. It’s a regular string value (REG_SZ), not an Expandable String Value (REG_EXPAND_SZ). As a result, %SystemRoot% does not get expanded in the string. Changing it like this should work:
Code:
@="C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe -NoProfile -ExecutionPolicy Bypass -Command \"Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public static class User32 { [DllImport(\\\"user32.dll\\\", SetLastError = true)] public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam); }' -ReferencedAssemblies System.Windows.Forms; Start-Sleep -Seconds 2; $null = [User32]::SendMessage((New-Object System.Windows.Forms.Form).Handle.ToInt32(), 0x0112, 0xF170, 2);\""
 

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming F16 (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Mouse
    Logitech G402
    Keyboard
    Logitech K800
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
I had to modify the command a bit below for it to work.

Code:
@="powershell.exe -NoProfile -ExecutionPolicy Bypass -Command \"Add-Type -TypeDefinition 'using System; using System.Runtime.InteropServices; public static class User32 { [DllImport(\\\"user32.dll\\\", SetLastError = true)] public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam); }' -ReferencedAssemblies System.Windows.Forms; Start-Sleep -Seconds 2; $null = [User32]::SendMessage((New-Object System.Windows.Forms.Form).Handle.ToInt32(), 0x0112, 0xF170, 2);\""
fwiw, i tried that code and it wouldnt do anything on my system either. may just be something i have implemented on my system

^ started posting that hours ago but accidentally closed the tab and forgot to come back to it. not sure why @Brink code didnt work for my pc either. no errors, nothing. just doesnt do anything.
I see what I did wrong. It’s a regular string value (REG_SZ), not an Expandable String Value (REG_EXPAND_SZ). As a result, %SystemRoot% does not get expanded in the string. Changing it like this should work:
notta for me. now im curious why it wont run on my pc. tomorrow i'll run it on a few other test PCs and see if it works for them
 

My Computer

System One

  • OS
    Windows 11 Pro
fwiw, i tried that code and it wouldnt do anything on my system either. may just be something i have implemented on my system

^ started posting that hours ago but accidentally closed the tab and forgot to come back to it. not sure why @Brink code didnt work for my pc either. no errors, nothing. just doesnt do anything.

notta for me. now im curious why it wont run on my pc. tomorrow i'll run it on a few other test PCs and see if it works for them
You haven't uninstalled/disabled .NET Framework, have you?
 

My Computers

System One System Two

  • OS
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Asus TUF Gaming F16 (2024)
    CPU
    i7 13650HX
    Memory
    16GB DDR5
    Graphics Card(s)
    GeForce RTX 4060 Mobile
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    512GB SSD internal
    37TB external
    PSU
    Li-ion
    Cooling
    2× Arc Flow Fans, 4× exhaust vents, 5× heatpipes
    Keyboard
    Logitech K800
    Mouse
    Logitech G402
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF
  • Operating System
    11 Home
    Computer type
    Laptop
    Manufacturer/Model
    Medion S15450
    CPU
    i5 1135G7
    Memory
    16GB DDR4
    Graphics card(s)
    Intel Iris Xe
    Sound Card
    Eastern Electric MiniMax DAC Supreme; Emotiva UMC-200; Astell & Kern AK240
    Monitor(s) Displays
    Sony Bravia XR-55X90J
    Screen Resolution
    3840×2160
    Hard Drives
    2TB SSD internal
    37TB external
    PSU
    Li-ion
    Mouse
    Logitech G402
    Keyboard
    Logitech K800
    Internet Speed
    20Mbit/s up, 250Mbit/s down
    Browser
    FF

Latest Support Threads

Back
Top Bottom