@echo off
setlocal
 title PiecesPC - Battery Diagnostic Tool
 echo ========================================
 echo    PiecesPC - Battery Diagnostic Tool
 echo ========================================
 echo.
 echo This tool creates a Windows battery report.
 echo No information is sent automatically.
 echo The report may contain your computer name and battery usage history.
 echo.
 choice /C YN /M "Generate the report now"
 if errorlevel 2 exit /b 0
 powershell.exe -NoProfile -Command "$ErrorActionPreference='Stop'; try { $desktop=[Environment]::GetFolderPath('DesktopDirectory'); if (-not (Test-Path -LiteralPath $desktop)) { throw 'Desktop folder unavailable.' }; $report=Join-Path $desktop ('PiecesPC-Battery-Report-'+(Get-Date -Format 'yyyyMMdd-HHmmss')+'.html'); & powercfg.exe /batteryreport /output $report; if ($LASTEXITCODE -ne 0 -or -not (Test-Path -LiteralPath $report)) { throw 'Windows could not generate the battery report.' }; Write-Host ''; Write-Host 'SUCCESS: Battery report saved to your Desktop.'; Write-Host $report; Write-Host 'Please send this HTML file to the seller through an agreed supported method.'; Start-Process -FilePath $report } catch { Write-Host ('ERROR: '+$_.Exception.Message); exit 1 }"
 if errorlevel 1 echo If necessary, try again using Run as administrator.
 echo.
 pause
 endlocal
