@echo off

REM
set APP_NAME=storm_launcher.exe
set DOWNLOAD_URL=https://cartier.gg/files/storm/storm_launcher.exe

echo Updating application: %APP_NAME%

REM
if exist "%APP_NAME%" (
    echo Removing old version...
    del "%APP_NAME%"
    if errorlevel 1 (
        echo Error: Could not remove old file. It may be running.
        pause
        exit /b 1
    )
)

REM
echo Downloading new version...
curl -L -o "%APP_NAME%" "%DOWNLOAD_URL%"
if errorlevel 1 (
    echo Error: Download failed.
    pause
    exit /b 1
)

REM
if not exist "%APP_NAME%" (
    echo Error: Downloaded file not found.
    pause
    exit /b 1
)

echo Download complete. Starting application...
start "" "%APP_NAME%"

echo Application started successfully.
pause