@echo off
setlocal
set "OLP_BASE_URL=https://sos.miraesw.com/olp"
set "OLP_DIR=%LOCALAPPDATA%\MiraeSW\OLP"
if not exist "%OLP_DIR%" mkdir "%OLP_DIR%"
powershell -NoProfile -ExecutionPolicy Bypass -Command "$dir=Join-Path $env:LOCALAPPDATA 'MiraeSW\OLP'; New-Item -ItemType Directory -Force -Path $dir | Out-Null; Invoke-WebRequest -UseBasicParsing 'https://sos.miraesw.com/olp/license/launcher.py' -OutFile (Join-Path $dir 'olp_license_launcher.py')"
if errorlevel 1 (
  echo OLP license launcher download failed.
  pause
  exit /b 1
)
where py >nul 2>nul
if %errorlevel%==0 (
  py -3 "%OLP_DIR%\olp_license_launcher.py" --url "%OLP_BASE_URL%" --browser default
) else (
  python "%OLP_DIR%\olp_license_launcher.py" --url "%OLP_BASE_URL%" --browser default
)
