err0r.net


<my little piece of the internet/>

Instantly Sleep Your Monitors With a One-Click BAT File (Windows 11)


avatar

Want a quick way to turn off your monitors immediately, without putting your PC to sleep? This tiny batch file does exactly that. Your screens will go dark instantly and wake back up the moment you move the mouse or hit a key.

What this does

This script sends Windows the “turn off display” command. It does not:

  • shut down your PC

  • hibernate

  • close apps

  • stop downloads, streams, or music

It only puts your display(s) to sleep until you interact again.


Step 1: Create the batch file

  1. Open Notepad

  2. Paste this code:

@echo off
powershell -command "(Add-Type '[DllImport(\"user32.dll\")] public static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name Native -Namespace Win32 -PassThru)::SendMessage(0xFFFF,0x112,0xF170,2)"
  1. Click File -> Save As

  2. Set:

    • File name: SleepMonitors.bat

    • Save as type: All Files (*.*)

    • Encoding: UTF-8 (optional, but fine)

  3. Save it somewhere easy like your Desktop.


Step 2: Run it

Double-click SleepMonitors.bat.

Your screens should go dark immediately.

To wake them:

  • move your mouse, or

  • press any key


Optional: Make it feel like a real “button” (desktop shortcut + icon)

Create a shortcut

  1. Right-click SleepMonitors.bat

  2. Choose Show more options (if you’re on Windows 11’s compact menu)

  3. Click Create shortcut

Assign an icon

  1. Right-click the shortcut -> Properties

  2. Click Change Icon

  3. Browse to a .ico file you like

  4. Apply/OK


Optional: Set a keyboard hotkey

  1. Right-click the shortcut -> Properties

  2. Click into Shortcut key

  3. Press something like Ctrl + Alt + M

  4. Apply

Now you can sleep the monitors instantly from the keyboard.

Icon you can use:

sleep-monitors.ico
Size: 77.07 KBDownloads: 1


Troubleshooting

Nothing happens

  • Make sure you saved it as .bat and not .txt

  • Ensure the file contains both lines exactly, starting with @echo off

PowerShell warning / policy issues
This command runs a one-liner and typically works even on systems with stricter policies, but if yours is locked down, try running PowerShell as admin once, or use a different method (rundll32). Most Windows 11 systems are fine with the above.

Here is the bat file already done for you.

esleepmonitor.bat
Size: 233 bytesDownloads: 1


Comments 0
avatar
Your comment will appear after approval.
( characters remaining)