1

We can set low/critical battery sound notification but I don't know how to set a full battery sound notification, Is there any way to do that?

EDIT : I agree to the point that not all laptops charge to 100%, then my question rephrases from 100% to 95%, or maybe to get a notification at some specified %age...

Mukul Kumar
  • 714
  • 7
  • 17

1 Answers1

1

I cannot set a full battery sound notification, is there any way to do that?

Use the following batch file (Battery.cmd):

@echo off
setlocal EnableDelayedExpansion
rem set threshold value
set _threshold=95
:start
rem get the battery charge
rem use findstr to strip blank lines from wmic output
for /f "usebackq skip=1 tokens=1" %%i in (`wmic Path Win32_Battery Get EstimatedChargeRemaining ^| findstr /r /v "^$"`) do (
  set _charge=%%i
  echo !_charge!
  if !_charge! geq !_threshold! (
    echo charge reached
    goto :done
    ) else (
    rem wait for 10 minutes then try again
    timeout /t 600 /nobreak
    goto :start
    )
  )
:done
endlocal

Notes:

  • This batch file monitors the current battery percentage charge and prints "charge reached" when the charge reaches a user defined threshold value (in this case 95%). The batch file then ends. If the charge goes below the threshold, the user must manually run the batch file again.
  • Set _threshold as required.
  • Replace the echo charge reached command with a command to play your chosen sound.
  • Modify the timeout delay as required for your situation.

Further Reading

DavidPostill
  • 153,128
  • 77
  • 353
  • 394
  • That sure is useful...Thanks. BTW, I am guessing that there will be an open window all the time ? If that is the case then, Is there any way to have no window ? – Mukul Kumar Feb 12 '17 at 10:37
  • @MukulKumar [How to run .BAT files invisibly, without displaying the Command Prompt window](http://www.winhelponline.com/blog/run-bat-files-invisibly-without-displaying-command-prompt/) – DavidPostill Feb 12 '17 at 10:44