Skip to content

Instantly share code, notes, and snippets.

@kaiimran
Created May 31, 2020 02:57
Show Gist options
  • Save kaiimran/329b59e9e94ce6f7e8fa49eb28a11ae9 to your computer and use it in GitHub Desktop.
Save kaiimran/329b59e9e94ce6f7e8fa49eb28a11ae9 to your computer and use it in GitHub Desktop.
Windows notification when battery level is 99%
' Battery Fully Charged Notification VBS - checked every 5 minutes
' To run the script automatically on startup, put this file into startup directory:
' Press Win+R, Type shell:startup, click OK
' (C:\Users\YOU\AppData\Roaming\Microsoft\Windows\Start Menu\Programs\Startup)
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 > 98) Then msgbox "Battery is fully 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