How to have my laptop go to sleep when unplugged while lid shut? (Don't want it to go to sleep when closing lid and plugged in)

10

4

I've got a Lenovo Yoga 2 11 running Windows 10. I currently have it set to stay awake when the lid is closed and it is plugged in, and that is working exactly as intended. However, if the lid is closed and it is plugged in, when I unplug it, I want it to go to sleep.

Scenario: When I'm finished using my laptop at my desk (plugged in), I shut the lid. It does not go to sleep. When I grab my laptop to go to work, I unplug it (without opening and closing the lid). It is still awake.

This has led to numerous occasions where my laptop is dead when I go to use it since it sits and churns for a few hours until it dies.

Is there a way I can make it so it'll go to sleep when I unplug and the lid is closed?

Alex Kibler

Posted 2016-02-16T22:44:34.533

Reputation: 211

Not naively, that I'm aware of. Maybe there is something promising in the Lenovo Power Manager? In the Windows Power Options you can set the On Battery option to Sleep and the Plugged In option to Do Nothing, but I see your point, as the On Battery setting would not take effect after unplugging and would require you to open and close the lid. – root – 2016-02-17T15:08:45.370

1@root There is a method for that. – ds_secret – 2018-02-04T02:38:26.257

Answers

1

As you see here, all you need to do is

  1. Go to Control Panel
  2. Click on Hardware & Sound
  3. Click on Power Options
  4. Click on Choose when to turn off the display of Change when the computer sleeps
  5. Follow the Given Directions

ds_secret

Posted 2016-02-16T22:44:34.533

Reputation: 115

2This does not work! I have the above reference settings configured as follows:

When power is connected: Do not sleep when lid is closed.

When power is not connected: Sleep when lid is closed.

If I close the lid with power connected then subsequently disconnect power the laptop stays on! This makes it very easy to stow the laptop in a bag and have it overheat! At the very least it should switch to the on battery profile so it sleeps after a set number of minutes but this doesn't happen either on my laptop! – Jules – 2018-03-29T14:19:42.523

0

Method using a VBS background script that starts a batch script (made in windows 10). Turn on hibernation option when using this (explained below). Note that this isn't a super solid solution to your problem. The batch script will put your computer into a hybrid-sleep-hibernate mode if you have the hibernation option turned on (I do). I recommend turning on the hibernation option because, although turning it off will likely sleep the computer instead, there is a small possibility that it will power your computer down. In general, the batch method isn't very solid.

VBS portion:

Set Shell = CreateObject("WScript.Shell")
do
WScript.sleep 60000
Shell.run "batterysleep.bat"
loop

BAT portion:

set OnAC=false
set cmd=WMIC /NameSpace:\\root\WMI Path BatteryStatus Get PowerOnline
%cmd% | find /i "true" > nul && set OnAC=true
if %OnAC% == false %windir%\System32\rundll32.exe powrprof.dll,SetSuspendState Standby
  1. So first, you need to paste the VBS code into a .vbs file.
  2. Then, paste the BAT code into a .bat file in the same file location as the VBS file.
  3. After that, you will need to make a shortcut of your VBS file, copy it, and paste it into the startup folder (to make it run automatically on startup): C:\Users\[YOU USERNAME]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup

Basically, this code runs a VBS file in the background which opens a batch script every minute. This batch script will do the sleep action if your computer is not on A.C. power. To kill the process, type "taskkill /f /im wscript.exe" into the search, but note that this will kill all WScript processes. Again, please note that this is not a completely reliable solution.

gCo

Posted 2016-02-16T22:44:34.533

Reputation: 1