@echo off
setlocal

set "SCRIPT_URL=https://support.obergodmar.ru/scripts/windows.ps1"
set "SCRIPT_PATH=%TEMP%\rustdesk-support.ps1"

echo Downloading RustDesk support script...
powershell.exe -NoProfile -ExecutionPolicy Bypass -Command "try { [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri '%SCRIPT_URL%' -OutFile '%SCRIPT_PATH%' } catch { Write-Error $_; exit 1 }"
if errorlevel 1 (
  echo Failed to download RustDesk support script.
  pause
  exit /b 1
)

powershell.exe -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT_PATH%"
set "EXIT_CODE=%ERRORLEVEL%"

if not "%EXIT_CODE%"=="0" pause
exit /b %EXIT_CODE%
