@echo off
setlocal EnableDelayedExpansion

:: Read config.txt
for /f "usebackq tokens=1,* delims==" %%A in ("config.txt") do (
    set "%%A=%%B"
)

:: Validate configuration
if not exist "%PHP_PATH%" (
    echo ERROR: PHP executable not found:
    echo %PHP_PATH%
    pause
    exit /b 1
)

if not exist "%HEINZELMANN_PATH%\artisan" (
    echo ERROR: Laravel project not found:
    echo %HEINZELMANN_PATH%
    pause
    exit /b 1
)

cd /d "%HEINZELMANN_PATH%"

echo ========================================
echo Scheduler started
echo PHP: %PHP_PATH%
echo Heinzelmann: %HEINZELMANN_PATH%
echo ========================================

:loop
echo.
echo [%date% %time%] Running scheduler...
"%PHP_PATH%" artisan schedule:run

timeout /t 60 /nobreak >nul
goto loop