How to turn off screen with PowerShell?
9,519
Solution 1
From this TechNet scripting page:
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)
Solution 2
(Running this has the side effect of also locking the workstation in Windows 10. You will need to know the password in order to log back in)
Running in 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)
Would be the correct answer in order to turn off the display. Yes, it also turns off the display on a laptop using Powershell (and some .NET C# code)
Related videos on Youtube
![A.Ishah](https://i.stack.imgur.com/ZVQAn.jpg?s=256&g=1)
Comments
-
A.Ishah over 1 year
I need to be able to turn off my screen instantly manually.
I tried powercfg /change monitor-timeout-ac 0, but looks like setting the value to 0 turns it to never. Values like 0.1 also change it to never.
Is there any way I can set this value to 0 minutes, or is there another command that i can use to turn off my screen manually?