@echo off
setlocal enabledelayedexpansion

:: ====================== Configuration Area ======================
set "TARGET_EXE=squirebot.exe"

set "ARG_SERVER=www"
set "ARG_USERNAME=hello@mail.com"
set "ARG_PASSWORD=123456"
set "ARG_GAME=C:\Program Files (x86)\World of Warcraft\_forever_\Wow.exe"
set "ARG_SESSION=1"

set "WAIT_SECONDS=5"
:: =================================================================

cd /d "%~dp0" 2>nul || goto :end

:: ──────────────── Get game exe version ────────────────
echo [DEBUG] Reading version from:
echo [DEBUG]   "%ARG_GAME%"
echo.

:: Use temp file method - more reliable in batch
powershell -NoProfile -Command "(Get-Item -LiteralPath '%ARG_GAME%').VersionInfo.FileVersion" > "%temp%\wow_ver.txt" 2>"%temp%\wow_err.txt"

set "ARG_VERSION="
set /p ARG_VERSION=<"%temp%\wow_ver.txt"

:: Clean up temp files
del "%temp%\wow_ver.txt" "%temp%\wow_err.txt" 2>nul


echo [DEBUG] Detected version: !ARG_VERSION!
echo.

:: Build arguments
set "ARGS=/server %ARG_SERVER% /username %ARG_USERNAME% /password %ARG_PASSWORD% /game "%ARG_GAME%" /session %ARG_SESSION% /pve /alt /version !ARG_VERSION!"

:: ──────────────── Preview ────────────────
echo =============================================
echo Command Preview:
echo =============================================
echo.
echo Target:   %TARGET_EXE%
echo Full args:
echo   %ARGS%
echo.
echo Details:
echo   - Server    = %ARG_SERVER%
echo   - Username  = %ARG_USERNAME%
echo   - Password  = %ARG_PASSWORD%
echo   - Game Path = "%ARG_GAME%"
echo   - Session   = %ARG_SESSION%
echo   - Plugin    = %ARG_PLUGIN%
echo   - Version   = !ARG_VERSION!
echo.

:: Execute
echo Starting %TARGET_EXE% ...
"%TARGET_EXE%" %ARGS%

echo Script finished. Press any key to close...
pause >nul

:end
exit