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
- So first, you need to paste the VBS code into a .vbs file.
- Then, paste the BAT code into a .bat file in the same file location as the VBS file.
- 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.
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