How can I turn off the monitor (i.e., "put it to sleep") via command line at the push of a button (or any other shortcut not requiring additional software)?

Hello,

  I don't like it when, after a pause working on my PC, the screen turns itself off as set up per "Power Options" on the control panel. That's why I set the threshold fairly high.
  Still, when I know I won't be needing the computer for a while, I want to save power and wish the sleep mode could be activated immediately. Turning the display off is not an option, since it has an integrated USB-hub -- turning it off completely would disconnect any connected device. Usually though the computer still runs and might need the connected resources.

  Ideally, by pushing a button (or starting a program or something), the display would immediately go into sleep mode.

  On systems before Vista and 7, IIRC, executing a command along the lines of:
rundll32.exe user32.dll,SendMessage (HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, 2);
  would do the trick. The dll would execute the command to put the monitor to sleep. One could create a shortcut or even integrate the command into a batch file, but unfortunately that doesn't seem to work on Vista or 7.

  Does anybody have an idea on how to do this on Windows 7?

  I would very much try to avoid having to install any additional software to help me out. (There are quite some small applications around, even free ones, that promise to do just that, but I would like to avoid them if possible. And I cannot believe that something this basic that could be done on XP cannot be done anymore on 7!)

  Thank you for your help,
NicApicella
 

Question Info


Last updated November 12, 2019 Views 64,154 Applies to:
Answer
Answer

Hello,

 

Sleep is one thing and Switching Off the Display is quite another.

I have found a way to switch off the Display in case you do not have a hardware switch or a Hotkey as in my Dell Inspiron Laptop (Windows 7).

 

Create a batch file with the following script:

echo off

C:\Windows\System32\powercfg.exe -Change -monitor-timeout-dc 1
C:\Windows\System32\powercfg.exe -Change -monitor-timeout-ac 1

START /MIN /WAIT C:\Windows\System32\scrnsave.scr -s

C:\Windows\System32\powercfg.exe -Change -monitor-timeout-dc m1
C:\Windows\System32\powercfg.exe -Change -monitor-timeout-ac m2

 

replace m1 and m2 with the idle time for switching off your display defined in control panel.

Control Panel > Power Options > whichever "Active" Power Plan > Change Plan Settings > Turn off the display setting (minutes).

For example in my laptop m1 = 10 and m2 = 30.

Now create a shortcut to this batch file and optionally assign a Hotkey and an Icon.

 

Explanation of the script:

The first two commands sets the Display Off idle time for the minimum possible setting of 1 Minute for both AC and DC (Battery) power. The third command put the system in Blank Screen Saver mode "instantly", and /WAIT for the screen saver application to terminate. After 1 minute of idle time the Monitor will switch off power completely.
Once the screen saver /WAIT is terminated by the wakeup event of a mouse movement or keystroke, the last two lines of code will revert the Display idle time-out to the original defined settings in Control Panel. This to ensure that after wake-up, the display does not turn-off every 1 minute of idle time out.

 

Regards,

Sushovon Sinha

 

28 people were helped by this reply

·

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.

Answer
Answer
You can activate sleep mode quickly from the start menu.  In the Start menu, right-click the shutdown choice and use the Properties option to change the default to be Sleep.  Then your sleep is always 1-click away.




If this was helpful, please vote by clicking the green triangle. If it solves the issue, click Propose as Answer. Thanks!
Shawn "Cmdr" Keene | Microsoft MVP - Windows Insider | CmdrKeene.com | tweet me: @LtCmdrKeene
Microsoft MVPs are independent experts offering real-world answers. Learn more at mvp.microsoft.com.

9 people were helped by this reply

·

Did this solve your problem?

Sorry this didn't help.

Great! Thanks for marking this as the answer.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this response?

Thanks for your feedback.