@echo off
title Windows Ag Yigini Sifirlama - Bilgisayar Borsasi
color 0E
setlocal

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 OUT=%USERPROFILE%\Desktop\Ag-Ayar-Yedegi.txt

cls
echo ============================================================
echo   WINDOWS AG YIGINI SIFIRLAMA
echo   bilgisayarborsasi.com.tr
echo ============================================================
echo.
echo  Yapilacaklar:
echo    1. Mevcut ayarlarin yedegi masaustune yazilir
echo    2. DNS onbellegi temizlenir
echo    3. IP kirasi yenilenir (release / renew)
echo    4. Winsock katmani sifirlanir
echo    5. TCP/IP yigini sifirlanir
echo    6. WinHTTP proxy ayari temizlenir
echo.
echo  UYARI: Elle girilmis SABIT IP, SABIT DNS ve PROXY ayarlari
echo  SILINIR. Kurumsal bir agda calisiyorsaniz once sistem
echo  yoneticinize danisin.
echo.
echo  Islem sonunda YENIDEN BASLATMA gerekir.
echo.
choice /c EH /n /m "Devam edilsin mi? (E=Evet / H=Hayir): "
if errorlevel 2 exit /b
echo.

echo [1/6] Mevcut ayarlar yedekleniyor...
echo ==== AG AYAR YEDEGI - %date% %time% ==== > "%OUT%"
ipconfig /all >> "%OUT%" 2>&1
netsh winhttp show proxy >> "%OUT%" 2>&1
powershell -NoProfile -Command "Get-DnsClientServerAddress -AddressFamily IPv4 | Format-List | Out-String -Width 200" >> "%OUT%" 2>&1
echo      TAMAM - %OUT%

echo [2/6] DNS onbellegi temizleniyor...
ipconfig /flushdns >nul 2>&1
echo      TAMAM

echo [3/6] IP kirasi yenileniyor...
ipconfig /release >nul 2>&1
ipconfig /renew >nul 2>&1
echo      TAMAM

echo [4/6] Winsock katmani sifirlaniyor...
netsh winsock reset >nul 2>&1
echo      TAMAM

echo [5/6] TCP/IP yigini sifirlaniyor...
netsh int ip reset >nul 2>&1
netsh int ipv4 reset >nul 2>&1
netsh int tcp reset >nul 2>&1
echo      TAMAM

echo [6/6] Proxy ayari temizleniyor...
netsh winhttp reset proxy >nul 2>&1
echo      TAMAM

echo.
echo ============================================================
echo   ISLEM TAMAMLANDI
echo ============================================================
echo.
echo  BILGISAYARI SIMDI YENIDEN BASLATIN.
echo  Yeniden baslatmadan bu degisiklikler etkili olmaz.
echo.
echo  Yeniden baslattiktan sonra internet hala gelmezse:
echo    - Ayarlar ^> Ag ve Internet ^> DNS'i el ile 1.1.1.1 yapin
echo    - Bilgisayari telefonun hotspot'una baglayip test edin
echo    - Sistem saatinin dogru oldugundan emin olun
echo.
echo  Eski ayarlariniz: %OUT%
echo  Rehber: bilgisayarborsasi.com.tr/rehber/internet-bagli-ama-yok
echo.
choice /c EH /n /m "Simdi yeniden baslatilsin mi? (E=Evet / H=Hayir, sonra yaparim): "
if errorlevel 2 goto son
shutdown /r /t 15 /c "Ag ayarlari sifirlandi, bilgisayar yeniden baslatiliyor."
echo.
echo  15 saniye icinde yeniden baslatilacak. Iptal icin: shutdown /a
:son
echo.
pause
