Last active
October 28, 2021 03:18
-
-
Save xsnpdngv/0829df7a0d35f80c7cfeb9df81eb58f2 to your computer and use it in GitHub Desktop.
battery full notification VB 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
' Battery Full Notification VBS - checking in each 5 min | |
' To start automatically on logon, put into the directory that opens on: | |
' Win+R: Open: [shell:startup] -> [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 > 97) | |
then msgbox "Battery is at " & iPercent & "%",vbInformation, "Battery monitor" | |
wscript.sleep 300000 ' 5 minutes | |
wend |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could you add sound alarm code to that script? thanks