Skip to content

Instantly share code, notes, and snippets.

@dwettstein
Last active July 13, 2021 19:48
Show Gist options
  • Save dwettstein/b4dc091089ff0814ae7b58c22c58ba6e to your computer and use it in GitHub Desktop.
Save dwettstein/b4dc091089ff0814ae7b58c22c58ba6e to your computer and use it in GitHub Desktop.
Get a battery report on Windows
:: ----------------------------------------------------------------------------
:: Get a battery report for your device as a HTML and XML file.
::
:: File-Name: battery_report.bat
:: Author: David Wettstein
:: Version: 1.1.0
:: License: Copyright (c) 2020-2021 David Wettstein,
:: licensed under the MIT License
:: (https://dwettstein.mit-license.org/)
:: Link: https://gist.github.com/dwettstein/b4dc091089ff0814ae7b58c22c58ba6e
::
:: Changelog:
:: 1.1.0, 2021-07-13, David Wettstein: Use current path of file
:: 1.0.0, 2020-11-26, David Wettstein: First implementation
:: ----------------------------------------------------------------------------
@echo off
setlocal
set duration_in_days=14
set currdate=%date:~-4%-%date:~-7,2%-%date:~-10,2%
echo %currdate%
set currpath=%~dp0
echo %currpath%
powercfg /batteryreport /output %currpath%\%currdate%_battery_report.html /Duration %duration_in_days%
powercfg /batteryreport /output %currpath%\%currdate%_battery_report.xml /XML /Duration %duration_in_days%
pause
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment