Guide | How To VBScript to get an alert when battery is charged - Windows

The associated guide may contain user-generated or external content.

KaptainBug

Level 12
Thread author
Verified
Dec 26, 2013
562
642
1,067
set oLocator = CreateObject("WbemScripting.SWbemLocator")
set oServices = oLocator.ConnectServer(".","root\wmi")
set oResults = oServices.ExecQuery("select * from batteryfullchargedcapacity")
for each oResult in oResults
iFull = oResult.FullChargedCapacity
next

while (1)
set oResults = oServices.ExecQuery("select * from batterystatus")
for each oResult in oResults
iRemaining = oResult.RemainingCapacity
bCharging = oResult.Charging
next
iPercent = ((iRemaining / iFull) * 100) mod 100
if bCharging and (iPercent > 95) Then msgbox "Battery is at " & iPercent & "%",vbInformation, "Battery monitor"
wscript.sleep 300000 ' 5 minutes
wend
Please note, I have changed 30000 to 300000 in the above script, which corresponds to 5 minutes.
Its also advisable, to change iPercent > 95 to iPercent > 90, because the script does not alert you when battery is fully charged, i.e., at 100%. So if the charging rate from 95-100% is less than 5 minutes, you will never get an alert. For this reason, I recommend to change the level to 90%.

Save the above script as .vbs extension and make a startup entry in Windows.

Source:
http://blogs.technet.com/b/jhoward/archive/2013/04/24/get-an-alert-when-my-battery-reaches-95.aspx

http://www.addictivetips.com/windows-tips/get-alerts-when-your-laptop-battery-is-low-or-full/
 
  • Like
Reactions: Oxygen
can u tell me the command for low battery same like "FullChargedCapacity" i want to write a script for low battery.......:D
 
can u tell me the command for low battery same like "FullChargedCapacity" i want to write a script for low battery.......:D
You don't need one for low battery as Windows will itself notify in such a case. You can change the low battery level by going to power options under control panel and change the low battery percentage.
 
when i watching movie the error show in background that's why some times i dint get the alert there is any method for show error in foreground....?
 
when i watching movie the error show in background that's why some times i dint get the alert there is any method for show error in foreground....?
When I used the script, message prompt always appear in foreground even when watching youtube videos on fullscreen. Don't know why it does not in your case.
I can prepare a script if you would like, that will play a notification sound along with the message prompt. So even if you miss the prompt you can get notified by the sound.
 
When I used the script, message prompt always appear in foreground even when watching youtube videos on fullscreen. Don't know why it does not in your case.
I can prepare a script if you would like, that will play a notification sound along with the message prompt. So even if you miss the prompt you can get notified by the sound.

Don't know if this will still reach you from 2018. Please add a notification sound to the script.