@echo off
title Steam "Failed to load steamui.dll" Onarim - Bilgisayar Borsasi
color 0B
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 "DESK=%USERPROFILE%\Desktop"
for /f "usebackq delims=" %%D in (`powershell -NoProfile -Command "[Environment]::GetFolderPath('Desktop')"`) do set "DESK=%%D"
set "OUT=%DESK%\Steam-Onarim-Raporu.txt"

:menu
cls
echo ============================================================
echo   STEAM "FAILED TO LOAD STEAMUI.DLL" ONARIM ARACI
echo   Windows 11 / Windows 10  -  bilgisayarborsasi.com.tr
echo ============================================================
echo.
echo   1. Teshis (hicbir ayar degismez)
echo   2. Windows Update'i ac ve guncelleme taramasini baslat
echo   3. Akilli Uygulama Denetimi'ni kapat + Steam'i onar  (ONERILEN)
echo   4. Sadece Steam'i onar (steamui.dll dosyalarini yenile)
echo   5. Akilli Uygulama Denetimi ayar sayfasini ac (tekrar acmak icin)
echo   6. Cikis
echo.
echo  Sira: once 1, sonra 2 ile Windows'u guncelleyip yeniden baslatin,
echo  ardindan bu araci tekrar calistirip 3'u secin.
echo.
choice /c 123456 /n /m "Seciminiz (1-6): "
if errorlevel 6 exit /b
if errorlevel 5 goto sayfa
if errorlevel 4 goto steam
if errorlevel 3 goto sac
if errorlevel 2 goto guncelle

:teshis
cls
echo  Teshis yapiliyor, lutfen bekleyin...
echo.
powershell -NoProfile -Command "$o = @(); $v = Get-ItemProperty 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion'; $pn = $v.ProductName; if ([int]$v.CurrentBuild -ge 22000) { $pn = $pn -replace 'Windows 10', 'Windows 11' }; $o += ('Windows        : ' + $pn + ' ' + $v.DisplayVersion + '  derleme ' + $v.CurrentBuild + '.' + $v.UBR); $s = $null; try { $s = Get-ItemPropertyValue 'HKLM:\SYSTEM\CurrentControlSet\Control\CI\Policy' -Name VerifiedAndReputablePolicyState -ErrorAction Stop } catch {}; $sn = switch ($s) { 0 { 'KAPALI' } 1 { 'ACIK (engelleyebilir)' } 2 { 'DEGERLENDIRME (engelleyebilir)' } default { 'bulunamadi (Windows 10 veya eski surum)' } }; $o += ('Akilli Uyg.Den.: ' + $sn); $b = [int]$v.CurrentBuild; $u = [int]$v.UBR; if (($b -eq 26100 -or $b -eq 26200) -and $u -lt 8116) { $o += 'Guncelleme     : EKSIK - Mart 2026 (KB5079391) oncesi. Once 2 ile guncelleyin.' } elseif ($b -ge 26100) { $o += 'Guncelleme     : yeterli (denetim sifirlamadan acilip kapatilabilir)' }; $p = (Get-ItemProperty 'HKCU:\Software\Valve\Steam' -ErrorAction SilentlyContinue).SteamPath; if (-not $p) { $p = (Get-ItemProperty 'HKLM:\SOFTWARE\WOW6432Node\Valve\Steam' -ErrorAction SilentlyContinue).InstallPath }; if ($p) { $p = $p -replace '/', '\'; $o += ('Steam klasoru  : ' + $p); $o += ('steamui.dll    : ' + $(if (Test-Path (Join-Path $p 'steamui.dll')) { 'var' } else { 'YOK' })) } else { $o += 'Steam klasoru  : bulunamadi' }; $e = @(); try { $e = Get-WinEvent -FilterHashtable @{LogName='Microsoft-Windows-CodeIntegrity/Operational'; StartTime=(Get-Date).AddDays(-14)} -MaxEvents 3000 -ErrorAction Stop | Where-Object { $_.Message -match 'steam' } } catch {}; $o += ('Engel kaydi    : son 14 gunde Steam ile ilgili ' + @($e).Count + ' kod butunlugu kaydi'); if (@($e).Count -gt 0) { $o += ('                 en son: ' + $e[0].TimeCreated + '  olay ' + $e[0].Id); $o += '  SONUC: Windows Steam dosyalarini engelliyor. 3. secenek bu sorunu cozer.' } elseif ($s -eq 1 -or $s -eq 2) { $o += '  SONUC: Denetim acik; steamui.dll hatasinin en olasi nedeni bu. 3. secenegi deneyin.' } else { $o += '  SONUC: Engel kaydi yok. 4. secenekle Steam dosyalarini yenileyin.' }; $o | ForEach-Object { Write-Host ('  ' + $_) }; $o | Out-File -FilePath $env:OUT -Encoding utf8"
echo.
echo  Rapor kaydedildi: %OUT%
echo.
pause
goto menu

:guncelle
cls
echo  Windows Update aciliyor ve tarama baslatiliyor...
start "" "ms-settings:windowsupdate"
UsoClient StartInteractiveScan >nul 2>&1
echo.
echo  Acilan pencerede "Guncellestirmeleri denetle" ve "Tumunu indir
echo  ve yukle" deyin. Bittiginde bilgisayari YENIDEN BASLATIN, sonra
echo  bu araci tekrar calistirip 3'u secin.
echo.
pause
goto menu

:sac
cls
echo ============================================================
echo   AKILLI UYGULAMA DENETIMI'NI KAPATMA
echo ============================================================
echo.
echo  Akilli Uygulama Denetimi (Smart App Control) Microsoft'un tanimadigi
echo  dosyalari engeller; Steam guncellemesinden sonra steamui.dll'i de
echo  engelleyebilir. Kapatinca Microsoft Defender antivirus CALISMAYA
echo  DEVAM EDER; yalnizca bu ek engelleme katmani kapanir.
echo.
echo  Not: Mart 2026 guncellemesinden (KB5079391) once denetim bir kez
echo  kapatilinca Windows sifirlanmadan geri acilamiyordu. Once 2 ile
echo  guncelleyin; guncelse 5 ile istediginiz zaman tekrar acabilirsiniz.
echo.
choice /c EH /n /m "Kapatilsin mi? (E=Evet / H=Hayir): "
if errorlevel 2 goto menu
reg add "HKLM\SYSTEM\CurrentControlSet\Control\CI\Policy" /v VerifiedAndReputablePolicyState /t REG_DWORD /d 0 /f >nul
if exist "%SystemRoot%\System32\CiTool.exe" "%SystemRoot%\System32\CiTool.exe" --refresh >nul 2>&1
echo.
echo  TAMAM - Akilli Uygulama Denetimi kapatildi.
echo.

:steam
echo  Steam onariliyor...
powershell -NoProfile -Command "$p = (Get-ItemProperty 'HKCU:\Software\Valve\Steam' -ErrorAction SilentlyContinue).SteamPath; if (-not $p) { $p = (Get-ItemProperty 'HKLM:\SOFTWARE\WOW6432Node\Valve\Steam' -ErrorAction SilentlyContinue).InstallPath }; if (-not $p) { Write-Host '  Steam klasoru bulunamadi. Steam''i steampowered.com adresinden yeniden kurun.' -ForegroundColor Red; exit 1 }; $p = $p -replace '/', '\'; Get-Process steam, steamwebhelper -ErrorAction SilentlyContinue | Stop-Process -Force; Start-Sleep -Seconds 2; $n = 0; foreach ($f in @(Get-ChildItem $p -Filter 'steamui.dll' -ErrorAction SilentlyContinue) + @(Get-ChildItem $p -Filter 'libswscale-*.dll' -ErrorAction SilentlyContinue)) { Remove-Item $f.FullName -Force -ErrorAction SilentlyContinue; $n++ }; $pk = Join-Path $p 'package'; if (Test-Path $pk) { Get-ChildItem $pk -Force | Remove-Item -Recurse -Force -ErrorAction SilentlyContinue }; Write-Host ('  ' + $n + ' bozuk dosya silindi, guncelleme paketi temizlendi.'); Write-Host '  Oyunlariniz ve kayitlariniz SILINMEDI.'; Start-Process (Join-Path $p 'steam.exe'); Write-Host '  Steam baslatildi; eksik dosyalari kendisi indirecek (birkac dakika).' -ForegroundColor Green"
echo.
echo  Steam acilip guncellemeyi bitirince giris ekrani gelmeli.
echo  Hata surerse bilgisayari yeniden baslatip Steam'i tekrar acin.
echo.
pause
goto menu

:sayfa
start "" "windowsdefender://appbrowser"
echo.
echo  Windows Guvenligi ^> Uygulama ve tarayici denetimi ^> Akilli
echo  Uygulama Denetimi ayarlari bolumunden durumu degistirebilirsiniz.
echo.
pause
goto menu
