Share this page 

Turn off screens from a batch fileTag(s): Misc Prog HowTo


powershell (Add-Type '[DllImport(\"user32.dll\")]^public static extern int PostMessage(int hWnd, int hMsg, int wParam, int lParam);' -Name a -Pas)::PostMessage(-1,0x0112,0xF170,2)

We are sending a message to the Windows OS to turn off all the monitors.

where

  1. -1 is HWND_BROADCAST
  2. 0x0112 is WM_SYSCOMMAND
  3. 0xF170 is SC_MONITORPOWER
  4. 2 is POWER OFF

mail_outline
Send comment, question or suggestion to howto@rgagnon.com