chatgpt解决记录
执行bat报错:
提示 无法加载电源效率诊断库(energy.dll)
在终端执行成功:
(base) PS C:\windows\system32> powercfg /BATTERYREPORT
电池使用时间报告已保存到文件路径 C:\windows\system32\battery-report.html。
(base) PS C:\windows\system32> powercfg /BATTERYREPORT /OUTPUT "D:\softWin\系统工具\电源管理\工具:耗电监控\000.html"
电池使用时间报告已保存到文件路径 D:\softWin\系统工具\电源管理\工具:耗电监控\000.html。
尝试:energy.dll下载放入system32 --- 无效
尝试:bat里加环境变量 --- 无效
set ORIG_PATH=%PATH%
set PATH=C:\Windows\System32;%ORIG_PATH%
...
set PATH=%ORIG_PATH%
尝试:bat里改变执行路径 --- 无效
...
cd /d C:\Windows\System32
或
C:\Windows\System32\powercfg.exe /BATTERYREPORT /OUTPUT "%filePathBattery%"
尝试:powershell一句话命令 ================唯一成功的=============
powercfg.exe /BATTERYREPORT /OUTPUT "D:\DEVICE_ini\笔记本-GPDWinMax2\驱动\电源管理\工具:耗电监控\batteryreport$(Get-Date -Format 'yyyyMMddHHmmss').html"
powercfg.exe /SLEEPSTUDY /OUTPUT "D:\DEVICE_ini\笔记本-GPDWinMax2\驱动\电源管理\工具:耗电监控\sleepstudy$(Get-Date -Format 'yyyyMMddHHmmss').html"
如果报错 无法执行操作。出现了意外错误(0x422): 无法启动服务,原因可能是已被禁用或与其相关联的设备没有启动。
启动 diagnostic policy service 服务即可
尝试:cmd一句话命令 --- 无效
尝试:bat里嵌套一层powershell调用 --- 无效
PowerShell -Command “& {powercfg.exe /batteryreport /output 'D:\softWin\系统工具\电源管理\工具:耗电监控\batteryreport$(Get-Date -Format 'yyyyMMddHHmmss').html'}”
chatgpt版本
@ECHO OFF
for /f "tokens=2 delims==" %%i in ('wmic OS Get localdatetime /value') do set timestampOrgin=%%i
set timestamp=%timestampOrgin:~0,8%_%timestampOrgin:~8,6%
ECHO %date% %time% timestamp=%timestamp% (from %date% %time%)
set fileDir=%~dp0%
if not exist "%fileDir%" mkdir "%fileDir%"
ECHO %date% %time% fileDir=%fileDir%
set filePathSystemPowerReport=%fileDir%%timestamp%_SystemPowerReport.html
ECHO %date% %time% filePathSystemPowerReport=%filePathSystemPowerReport%
set filePathBatteryReport=%fileDir%%timestamp%_BatteryReport.html
ECHO %date% %time% filePathBatteryReport=%filePathBatteryReport%
PowerShell -ExecutionPolicy Bypass -Command "& {powercfg.exe /SLEEPSTUDY /OUTPUT '%filePathSystemPowerReport%'}"
PowerShell -ExecutionPolicy Bypass -Command "& {powercfg.exe /BATTERYREPORT /OUTPUT '%filePathBatteryReport%'}"
ECHO %date% %time% [任意键关闭...]
pause>nul
@ECHO ON
google版本
@ECHO OFF
set ORIG_PATH=%PATH%
set PATH=C:\Windows\System32;%ORIG_PATH%
set timestampOrgin=%date:~0,4%%date:~5,2%%date:~8,2%%time:~0,2%%time:~3,2%%time:~6,2%
set timestamp=%timestampOrgin: =0%
ECHO timestamp=%timestamp% (from %date% %time%)
set fileDir=%~dp0
ECHO fileDir=%fileDir%
set filePathSleep=%fileDir%sleepstudy%timestamp%.html
ECHO filePathSleep=%filePathSleep%
set filePathBattery=%fileDir%batteryreport%timestamp%.html
ECHO filePathBattery=%filePathBattery%
C:\Windows\System32\powercfg.exe /SLEEPSTUDY /OUTPUT "%filePathSleep%"
C:\Windows\System32\powercfg.exe /BATTERYREPORT /OUTPUT "%filePathBattery%"
set PATH=%ORIG_PATH%
ECHO %date% %time% [任意键关闭...]
pause>nul
@ECHO ON
grok版本
@ECHO OFF
:: Check if script is running with administrator privileges
powershell -Command "Start-Process cmd -Verb RunAs -ArgumentList '/c %0 %*' -Wait; exit"
if %ERRORLEVEL% neq 0 (
ECHO.
echo 您需要以管理员身份运行此脚本。
pause
exit /b
)
for /f "tokens=2 delims==" %%i in ('wmic OS Get localdatetime /value') do set timestampOrgin=%%i
ECHO.
set timestamp=%timestampOrgin:~0,8%_%timestampOrgin:~8,6%
ECHO %date% %time% timestamp=%timestamp% (from %date% %time%)
ECHO.
set subDir=ReportHtml
set fileDir=%~dp0%subDir%\
if not exist "%fileDir%" mkdir "%fileDir%"
ECHO %date% %time% fileDir=%fileDir%
ECHO.
set filePathSystemSleepDiagnostics=%fileDir%%timestamp%_SystemSleepDiagnostics.html
ECHO %date% %time% filePathSystemSleepDiagnostics=%filePathSystemSleepDiagnostics%
ECHO.
set filePathSystemPowerReport=%fileDir%%timestamp%_SystemPowerReport.html
ECHO %date% %time% filePathSystemPowerReport=%filePathSystemPowerReport%
ECHO.
set filePathBatteryReport=%fileDir%%timestamp%_BatteryReport.html
ECHO %date% %time% filePathBatteryReport=%filePathBatteryReport%
ECHO.
set filePathEnergyReport=%fileDir%%timestamp%_EnergyReport.html
ECHO %date% %time% filePathEnergyReport=%filePathEnergyReport%
ECHO.
PowerShell -ExecutionPolicy Bypass -Command "& {powercfg.exe /systemsleepdiagnostics /OUTPUT '%filePathSystemSleepDiagnostics%'}"
ECHO.
PowerShell -ExecutionPolicy Bypass -Command "& {powercfg.exe /SLEEPSTUDY /OUTPUT '%filePathSystemPowerReport%'}"
ECHO.
PowerShell -ExecutionPolicy Bypass -Command "& {powercfg.exe /BATTERYREPORT /OUTPUT '%filePathBatteryReport%'}"
ECHO.
PowerShell -ExecutionPolicy Bypass -Command "& {powercfg.exe /energy /OUTPUT '%filePathEnergyReport%'}"
ECHO.
ECHO %date% %time% [任意键关闭...]
pause>nul
@ECHO ON
过去2分钟版本
@ECHO OFF
for /f "tokens=2 delims==" %%i in ('wmic OS Get localdatetime /value') do set timestampOrgin=%%i
set timestamp=%timestampOrgin:~0,14%
ECHO %date% %time% timestamp=%timestamp% (from %date% %time%)
set fileDir=%~dp0
ECHO %date% %time% fileDir=%fileDir%
set filePathEnergy=%fileDir%energy%timestamp%.html
ECHO %date% %time% filePathEnergy=%filePathEnergy%
PowerShell -ExecutionPolicy Bypass -Comman "& {powercfg -energy /duration 120 /output '%filePathEnergy%'}"
ECHO %date% %time% [任意键关闭...]
pause>nul
@ECHO ON