Created
January 16, 2023 14:32
-
-
Save irizwaririz/4224ca81e0cfe34925f8874687c79937 to your computer and use it in GitHub Desktop.
Battery Notification script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 > 79) Then msgbox "Battery is at " & iPercent & "%",vbInformation, "Battery Notification" | |
wscript.sleep 30000 ' 5 minutes | |
wend |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment