@echo off

:: `ping` is being used in place of `TIMEOUT`
:: https://www.ibm.com/support/pages/timeout-command-run-batch-job-exits-immediately-and-returns-error-input-redirection-not-supported-exiting-process-immediately

taskkill /im tracy.exe /f 2> nul

start %UserProfile%\Home\apps\tracy\capture.exe -o .tracy -f

echo Launching app...
build\bin\powerplay.exe

if NOT %errorlevel% == 0 (
    echo.
    echo Program failed
    pause
    exit /b 1
)

:: Give time for trace file to finish before opening tracy
ping -n 2 127.0.0.1 >NUL

echo Launching tracy...
start "" "%UserProfile%\Home\apps\tracy\Tracy.exe" ".tracy"
