@echo off
REM Ormur autostart launcher (FAZ4 zero-config PC installer).
REM Starts the THREE EXISTING run_*.cmd scripts in the same order the Windows service
REM would spawn them (sessiond -> serve -> tsnet), so buyers get the full stack at every
REM logon with no manual step. This ONLY orchestrates start order + timing; the real
REM config (state pins, .token, env) lives inside run_*.cmd and is reused verbatim.
REM
REM Launched hidden by ormur-startup.vbs (registered as the "Ormur" logon Scheduled Task)
REM so no console windows flash on the buyer's desktop. `start "" /b` keeps everything in
REM this one (already-hidden) console instead of opening extra windows.
cd /d "%~dp0"

REM 1) durable session host first (owns the ConPTY children + ring buffers on 127.0.0.1:8099)
start "" /b cmd /c "%~dp0run_sessiond.cmd"

REM give sessiond a moment to bind 127.0.0.1:8099 before the frontends proxy to it
ping -n 3 127.0.0.1 >nul

REM 2) browser proxy frontend (127.0.0.1:8088)  3) tailnet frontend (keyless reconnect, :7777)
start "" /b cmd /c "%~dp0run_serve_proxy.cmd"
start "" /b cmd /c "%~dp0run_tsnet_proxy.cmd"
