@echo off
title Kernel-Power 41 / Ani Kapanma Teshis Raporu - Bilgisayar Borsasi
color 0B
setlocal enabledelayedexpansion

net session >nul 2>&1
if %errorlevel% neq 0 (
  echo.
  echo Yonetici yetkisi gerekiyor. Onay penceresinde EVET deyin...
  powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
  exit /b
)

set STAMP=
for /f %%I in ('powershell -NoProfile -Command "Get-Date -Format yyyyMMdd-HHmm"') do set STAMP=%%I
if not defined STAMP set STAMP=rapor
set OUT=%USERPROFILE%\Desktop\Teshis-Raporu-%STAMP%
if not exist "%OUT%" mkdir "%OUT%"

cls
echo ============================================================
echo   ANI KAPANMA TESHIS RAPORU
echo   bilgisayarborsasi.com.tr
echo ============================================================
echo.
echo  Bu arac SADECE OKUR. Hicbir ayar, servis veya kayit
echo  defteri degeri degistirmez.
echo.
echo  Rapor klasoru:
echo  %OUT%
echo.
echo  Toplanan bilgiler:
echo    - Kernel-Power 41 ve beklenmedik kapanma (6008) kayitlari
echo    - Mavi ekran (1001 BugCheck) ve donanim hatasi (WHEA) kayitlari
echo    - Minidump dosya listesi
echo    - Disk sagligi (SMART) ve sistem ozeti
echo    - Laptoplarda batarya saglik raporu
echo.
echo  Islem 1-3 dakika surer.
echo.
pause
echo.

echo [1/6] Kernel-Power 41 ve kapanma kayitlari...
powershell -NoProfile -Command "$ErrorActionPreference='SilentlyContinue'; $e = Get-WinEvent -FilterHashtable @{LogName='System'; Id=41,6008,1074,1076; StartTime=(Get-Date).AddDays(-30)} | Select-Object TimeCreated,Id,ProviderName,Message; if ($e) { $e | Format-List | Out-String -Width 200 } else { 'Son 30 gunde kayit bulunamadi.' }" > "%OUT%\01-kapanma-kayitlari.txt" 2>&1
echo      TAMAM

echo [2/6] Mavi ekran ve donanim hatasi kayitlari...
powershell -NoProfile -Command "$ErrorActionPreference='SilentlyContinue'; $e = Get-WinEvent -FilterHashtable @{LogName='System'; Id=1001,17,18,117,129,153; StartTime=(Get-Date).AddDays(-30)} | Select-Object TimeCreated,Id,ProviderName,Message; if ($e) { $e | Format-List | Out-String -Width 200 } else { 'Kayit bulunamadi.' }" > "%OUT%\02-mavi-ekran-donanim.txt" 2>&1
echo      TAMAM

echo [3/6] Minidump listesi...
if exist "%SystemRoot%\Minidump" (
  dir /o-d "%SystemRoot%\Minidump" > "%OUT%\03-minidump-listesi.txt" 2>&1
) else (
  echo Minidump klasoru yok - mavi ekran kaydedilmemis. > "%OUT%\03-minidump-listesi.txt"
)
echo      TAMAM

echo [4/6] Disk sagligi...
powershell -NoProfile -Command "$ErrorActionPreference='SilentlyContinue'; Get-PhysicalDisk | Select-Object FriendlyName,MediaType,HealthStatus,OperationalStatus,@{n='BoyutGB';e={[math]::Round($_.Size/1GB,1)}} | Format-Table -AutoSize | Out-String -Width 200; 'SMART Durumu:'; Get-WmiObject -Namespace root\wmi -Class MSStorageDriver_FailurePredictStatus | Select-Object InstanceName,PredictFailure | Format-List | Out-String -Width 200; 'Birimler:'; Get-Volume | Format-Table -AutoSize | Out-String -Width 200" > "%OUT%\04-disk-sagligi.txt" 2>&1
echo      TAMAM

echo [5/6] Sistem ozeti ve guc ayarlari...
powershell -NoProfile -Command "$ErrorActionPreference='SilentlyContinue'; Get-CimInstance Win32_ComputerSystem | Select-Object Manufacturer,Model,TotalPhysicalMemory | Format-List; Get-CimInstance Win32_Processor | Select-Object Name,MaxClockSpeed | Format-List; Get-CimInstance Win32_BIOS | Select-Object Manufacturer,SMBIOSBIOSVersion,ReleaseDate | Format-List; Get-CimInstance Win32_VideoController | Select-Object Name,DriverVersion,DriverDate | Format-List; 'Windows: ' + (Get-CimInstance Win32_OperatingSystem).Caption + ' ' + (Get-CimInstance Win32_OperatingSystem).Version" > "%OUT%\05-sistem-ozeti.txt" 2>&1
powercfg /a >> "%OUT%\05-sistem-ozeti.txt" 2>&1
echo      TAMAM

echo [6/6] Batarya raporu (laptop ise)...
powercfg /batteryreport /output "%OUT%\06-batarya-raporu.html" >nul 2>&1
if not exist "%OUT%\06-batarya-raporu.html" echo Batarya bulunamadi ^(masaustu olabilir^). > "%OUT%\06-batarya-raporu.txt"
echo      TAMAM

echo.
echo ============================================================
echo   RAPOR HAZIR
echo ============================================================
echo.
echo  Klasor: %OUT%
echo.
echo  01-kapanma-kayitlari.txt dosyasindaki "BugcheckCode" satirina bakin:
echo     0        -^> mavi ekran YOK, neden elektriksel (guc/isi/donanim)
echo     0 degil  -^> aslinda mavi ekran yasanmis
echo.
echo  Yorumlamakta zorlanirsaniz bu klasoru zip'leyip
echo  WhatsApp'tan bize gonderin, ucretsiz on degerlendirme yapalim.
echo  Rehber: bilgisayarborsasi.com.tr/rehber/kernel-power-41-hatasi
echo.
start "" "%OUT%"
pause
