1

I've been using nircmd to turn off the monitor/display of various PCs like so:

nircmd.exe cmdwait 1000 monitor off

The cmdwait 1000 part just adds a 1 second delay (to let the last keystroke and mouse movement end) before turning off the display. This has worked for 10+ years.

I just now came across a Win10 PC that actually goes to sleep from this command instead of just turning off the monitor. What could be causing this, and how can it be fixed?

The PC in question in an ASUS Zenbook. Let me know if any more information is needed.

Update: I also tried this WinAPI call via powershell to turn off the display, and it also results in the PC going to sleep:

(Add-Type -MemberDefinition "[DllImport(""user32.dll"")]`npublic static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);" -Name "Win32SendMessage" -Namespace Win32Functions -PassThru)::SendMessage(0xffff, 0x0112, 0xF170, 2)
Bort
  • 1,474
  • 3
  • 18
  • 36
  • I have Nirsoft apps, the monitor app, and a batch file to turn the Monitor off. Works fine on all machines. On your problem machine, update BIOS and then see if there is a power manager you can update. Then go to Windows Advanced settings, make sure Suspend settings are good. Turn Hibernation off while testing these settings. – John Jan 17 '21 at 20:46
  • Can you elaborate on "*go to Windows Advanced settings, make sure Suspend settings are good*" ? – Bort Jan 17 '21 at 20:56
  • Control Panel, Power Options, Edit Plan Settings. Then in the there, choose Change Advanced Power Settings. In the dialogue Window that comes up, look in the Sleep settings (expand it) and set Suspend to sensible values (say after 20 minutes on battery, Never on AC - plugged in) and set Hibernate to disabled. – John Jan 17 '21 at 21:00
  • @John - It was set to sleep after 20 minutes on battery and after 3hrs on AC. I changed it to never on AC, but that didn't help. I also tried disabling hibernation with powercfg.exe but there was no change in outcome. I'm not sure how those settings would come in to play here. The BIOS is fresh and the ASUS SW updater says everything else is up to date as well. – Bort Jan 17 '21 at 21:09
  • Try nircmd monitor off without the wait. Then try reducing the wait by half or more and see if that works. – John Jan 17 '21 at 21:12
  • @John - Removing the wait just results in a swifter sleep :( I also tried a WinAPI call from power shell and that also goes to sleep. Seems this will be a difficult one. – Bort Jan 17 '21 at 21:46
  • There must be some underlying issue with your machine. In a normal machine, setting the monitor to black does not cause suspend - desktop or laptop. – John Jan 17 '21 at 21:55
  • Try the following and make sure everything completes properly. Open cmd.exe with Run as Administrator and run: dism.exe /online /cleanup-image /startcomponentcleanup , dism.exe /online /cleanup-image /restorehealth , SFC /SCANNOW . Restart when done and test. – John Jan 17 '21 at 22:01
  • @John Thanks but there's no change after that. – Bort Jan 18 '21 at 02:15
  • You may have to back up the data (all of it) and reinstall Windows 10. I cannot see any other solution at this point. – John Jan 18 '21 at 02:17

2 Answers2

1

I critically need a hack to accomplish the same.

Things have changed since Windows 10. Now, Microsoft disallows a simple light-off for the screen! Actually, Power Management in Windows hasn't worked right in any version of Windows I've used, and now they've deliberately added to the blight.

Microsoft's tech-support isn't of any help with this. See my long chat with them from yesterday here: https://docs.google.com/document/d/15LmihHAiiWgJQsE2Y_kafURWFfGQ82ekmtXH-WD0xHM/edit?usp=sharing

For those who can program, acting on system power management messages like WM_POWERBROADCAST might be a work-around/solution. However, I've failed so far to detect that message when issuing a command to turn off the monitor via "nircmd.exe monitor async_off" or a SendMessage command.

See also: https://docs.microsoft.com/en-us/windows/win32/power/system-power-states

Sleep (Modern Standby) S0 low-power idle

https://docs.microsoft.com/en-us/windows-hardware/design/device-experiences/modern-standby "Windows 10 Modern Standby (Modern Standby) expands the Windows 8.1 Connected Standby power model. Connected Standby, and consequently Modern Standby, enable an instant on / instant off user experience, similar to smartphone power models."

["instant on" here is a lie. I get a 2 second delay on a very costly laptop. Plus, when the laptop monitor is shut off, Win11 turns off most other activity too, like scripts that are running, downloads, etc.! Since when does the definition of "monitor off" mean put the entire computer into sleep/standby? Is Microsoft mocking us?]

rs20
  • 11
  • 1
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – DarkDiamond Feb 08 '22 at 16:43
  • This does not really answer the question. If you have a different question, you can ask it by clicking [Ask Question](https://superuser.com/questions/ask). To get notified when this question gets new answers, you can [follow this question](https://meta.stackexchange.com/q/345661). Once you have enough [reputation](https://superuser.com/help/whats-reputation), you can also [add a bounty](https://superuser.com/help/privileges/set-bounties) to draw more attention to this question. - [From Review](/review/late-answers/1107320) – bad_coder Feb 08 '22 at 17:19
  • Oops. I should have added that as a comment, not an answer, as I don't have an answer quite yet, other than attempting to program a work-around (by possibly working with system messages sent to applications), which I've yet to do. – rs20 Feb 08 '22 at 20:44
  • If you want the question answered, be sure to upvote it so it gets more exposure. – Bort Feb 08 '22 at 21:19
0

turn monitor off

Im on Windows10x64, doing it as shortcut as described on this video working

right click > New Shortcut paste :

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)"

prevent computer to go to sleep

you have to go Control Panel > Power Options > Change when the computer sleeps > choose never for 'Put the computer to sleep'

if for any reason, these is not working search google for mouse jiggler

Zakari
  • 101
  • 1