Last active
June 12, 2017 10:06
-
-
Save mansouryaacoubi/fffd6d44b0dd769b3f1c5dae48360ccd to your computer and use it in GitHub Desktop.
Battery Level Retrieval from Windows Management Instrumentation Command-line for Notebooks
This file contains 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
@echo off | |
REM @name MYBatteryLevel | |
REM @fullname Mansour Yaacoubi Battery Level Tool | |
REM @filename batterylevel.bat | |
REM @author Mansour Yaacoubi | |
REM @timestamp 04:09 PM June 7th, 2017 | |
REM @country Germany | |
REM @description This batch-script retrieves the battery level from WMIC | |
REM This is the command that retrieves the battery level: | |
REM WMIC PATH Win32_Battery Get EstimatedChargeRemaining /format:list | |
for /f "tokens=2 delims==" %%a in ( 'WMIC PATH Win32_Battery Get EstimatedChargeRemaining /format:list' ) do ( | |
set batlev=%%a | |
if [%batlev%] == [] ( | |
echo Battery information temporarily or permanently unavailable. | |
goto eof | |
) | |
echo Battery Level: %batlev%%% [battery] | |
) | |
:eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment