@echo off
title Windows 11 Lite - WebView Fix (SAFE)
color 0A

:: ADMIN CHECK
net session >nul 2>&1
if %errorlevel% neq 0 (
    echo Run this as Administrator.
    pause
    exit
)

echo =========================================
echo   Windows 11 Lite - WebView Fix (SAFE)
echo =========================================
echo.

:: ENABLE SERVICES
echo Enabling services...
sc config bits start= demand >nul
sc config wuauserv start= demand >nul
sc config cryptsvc start= auto >nul
sc config edgeupdate start= demand >nul
sc config edgeupdatem start= demand >nul

net start bits >nul 2>&1
net start wuauserv >nul 2>&1
net start cryptsvc >nul 2>&1
echo Services ready.
echo.

:: REMOVE EDGE POLICY BLOCKS
echo Removing Edge policy blocks...
reg delete "HKLM\SOFTWARE\Policies\Microsoft\Edge" /f >nul 2>&1
reg delete "HKCU\SOFTWARE\Policies\Microsoft\Edge" /f >nul 2>&1
echo Policies cleared.
echo.

:: DOWNLOAD FOLDER
set TEMP_DIR=%TEMP%\WebViewFix
mkdir "%TEMP_DIR%" >nul 2>&1
cd /d "%TEMP_DIR%"

:: INSTALL WEBVIEW2
echo Downloading WebView2 Runtime...
curl -L -o WebView2.exe https://go.microsoft.com/fwlink/p/?LinkId=2124703
echo Installing WebView2...
WebView2.exe /silent /install
echo WebView2 attempted.
echo.

:: INSTALL VC++
echo Downloading VC++ runtimes...
curl -L -o vc_redist.x64.exe https://aka.ms/vs/17/release/vc_redist.x64.exe
curl -L -o vc_redist.x86.exe https://aka.ms/vs/17/release/vc_redist.x86.exe

vc_redist.x64.exe /install /quiet /norestart
vc_redist.x86.exe /install /quiet /norestart
echo VC++ installed.
echo.

:: CLEANUP
cd /d %TEMP%
rmdir /s /q "%TEMP_DIR%" >nul 2>&1

echo =========================================
echo   Completed (DISM skipped - safe)
echo =========================================
echo.
echo Reboot is recommended.
pause
