@echo off
setlocal EnableExtensions
title Cloudflared SSH setup

set "SCRIPT=%~dp0Setup-CloudflaredSsh.ps1"
if not exist "%SCRIPT%" (
    echo ERROR: Setup-CloudflaredSsh.ps1 not found next to this file.
    echo Put both files in the same folder.
    pause
    exit /b 1
)

powershell.exe -NoProfile -Command "Unblock-File -Path '%SCRIPT%' -ErrorAction SilentlyContinue"
powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT%"

echo.
if exist "%ProgramData%\cloudflared\ssh-connection-info.txt" (
    echo ===== Connection info =====
    powershell.exe -NoProfile -Command "Get-Content -Raw -Encoding UTF8 (Join-Path $env:ProgramData 'cloudflared\ssh-connection-info.txt')"
    echo ============================
)
echo.
echo Done. Press any key to close this window...
pause >nul
