📎 AI Summary:
The thread discusses methods to turn computer monitors on and off via command line on Windows 10. The original poster seeks a simple command to control multiple monitors, and later shares a solution they found that forces monitors off when run as administrator. An additional contributor provides an alternative approach using batch and PowerShell scripts, including source code for turning off all monitors, indicating a general interest in programmable monitor control.

MIRKOSOFT

Active Member
Joined
Sep 26, 2019
Messages
60
Thread Author #1
Hi!

I'm new here. I have installed Windows 10.1903 Pro x64.
I'm using many ways to realize tasks. Now I want to ask if is possible to turn on or off monitor (in my case 3 monitors) connected to computer by any command. Best in command line - it needs not extra options, I can plan it by my wish or so, only one option will be useful - specify selected monitor.

Thank you for help.
 

Solution
Someone at Microsoft has created a batch file that turns off all monitors when launched. You can download the batch file from the link above or create one on your own with the following code:

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)

A PowerShell Script
Similar to the batch file above, here is a PowerShell script file that you can download and run for yourself.
Here is the source code if you are interested:

Code:
function Set-DisplayOff



{



$code = @"



using System;



using System.Runtime.InteropServices;



public class API



{



[DllImport("user32.dll")]



public...

MIRKOSOFT

Active Member
Joined
Sep 26, 2019
Messages
60
Thread Author #2
I found solution over the web.
You can use attached in archive - run as admin. It forces monitor(s) off after start.
Note: I'm not author, only copied and tested, works.

Miro
 

Attachments

AdrianG001

Senior Member
Joined
Feb 19, 2018
Messages
108
Someone at Microsoft has created a batch file that turns off all monitors when launched. You can download the batch file from the link above or create one on your own with the following code:

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)

A PowerShell Script
Similar to the batch file above, here is a PowerShell script file that you can download and run for yourself.
Here is the source code if you are interested:

Code:
function Set-DisplayOff



{



$code = @"



using System;



using System.Runtime.InteropServices;



public class API



{



[DllImport("user32.dll")]



public static extern



int SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);style='box-sizing: border-box'>

}



"@



$t = Add-Type -TypeDefinition $code -PassThru



$t::SendMessage(0xffff, 0x0112, 0xf170, 2)



}



Set-DisplayOff


Regards,
Adrian
 

Solution