@echo off
setlocal

for %%I in ("%~dp0.") do set "SCRIPT_DIR=%%~fI"
set "PS_SCRIPT=%SCRIPT_DIR%\github_download_latest.ps1"

if not exist "%PS_SCRIPT%" (
  echo Missing script: %PS_SCRIPT%
  exit /b 1
)

powershell -ExecutionPolicy Bypass -File "%PS_SCRIPT%" %*
set "EXIT_CODE=%ERRORLEVEL%"

if not "%EXIT_CODE%"=="0" (
  echo.
  echo Script failed with exit code %EXIT_CODE%.
  exit /b %EXIT_CODE%
)

echo.
echo Done.
