Skip to content

Instantly share code, notes, and snippets.

@ComradeCat24
Created March 11, 2021 06:21
Show Gist options
  • Save ComradeCat24/0005c511af5811eeec35385cfd0aa447 to your computer and use it in GitHub Desktop.
Save ComradeCat24/0005c511af5811eeec35385cfd0aa447 to your computer and use it in GitHub Desktop.
Battery Warning when charged upto a Limit {here 80%}
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 > 80) Then msgbox "Battery is 80% charged"
wscript.sleep 30000 ' 5 minutes
wend
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment