@echo off
REM ============================================================
REM  KIOSK CBT - WINDOWS 7 KHUSUS
REM  Prioritas: Chrome (v109 terakhir utk Win 7), fallback IE11 -k
REM  Edge Chromium baru tidak support Win 7, jangan dipaksa
REM  Buka http://192.168.100.14 fullscreen mode kiosk
REM  Taruh file ini di shell:startup
REM  Keluar kiosk: Alt+F4
REM ============================================================
setlocal
set "URL=http://192.168.100.14"

REM --- Tunggu server CBT nyala (maks ~60 detik) ---
set /a TRY=0
:CEK_SERVER
ping -n 1 -w 1000 192.168.100.14 | find "TTL=" >nul
if not errorlevel 1 goto SERVER_OK
set /a TRY+=1
if %TRY% GEQ 20 goto SERVER_OK
timeout /t 3 /nobreak >nul
goto CEK_SERVER
:SERVER_OK

taskkill /F /IM chrome.exe >nul 2>&1
taskkill /F /IM iexplore.exe >nul 2>&1
timeout /t 2 /nobreak >nul

REM --- 1. Chrome semua lokasi instalasi ---
if exist "%ProgramFiles%\Google\Chrome\Application\chrome.exe" (
  start "" "%ProgramFiles%\Google\Chrome\Application\chrome.exe" --kiosk %URL% --incognito --disable-save-password-bubble --no-first-run --disable-translate --noerrdialogs
  exit /b
)
if exist "%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe" (
  start "" "%ProgramFiles(x86)%\Google\Chrome\Application\chrome.exe" --kiosk %URL% --incognito --disable-save-password-bubble --no-first-run --disable-translate --noerrdialogs
  exit /b
)
if exist "%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe" (
  start "" "%LOCALAPPDATA%\Google\Chrome\Application\chrome.exe" --kiosk %URL% --incognito --disable-save-password-bubble --no-first-run --disable-translate --noerrdialogs
  exit /b
)

REM --- 2. IE11 fallback: -k = kiosk fullscreen ---
if exist "%ProgramFiles%\Internet Explorer\iexplore.exe" (
  start "" "%ProgramFiles%\Internet Explorer\iexplore.exe" -k %URL%
  exit /b
)
if exist "%ProgramFiles(x86)%\Internet Explorer\iexplore.exe" (
  start "" "%ProgramFiles(x86)%\Internet Explorer\iexplore.exe" -k %URL%
  exit /b
)

echo Chrome / IE tidak ditemukan di PC Win 7 ini.
echo Install Chrome v109 dulu, lalu jalankan lagi file ini.
pause
exit /b 1
