@echo off
:: Soporte remoto de Adandaa: instala RustDesk y lo conecta al servidor rs.adandaa.com.
:: Adandaa remote support: installs RustDesk and points it to the rs.adandaa.com server.
setlocal
set "VER=1.5.0"
set "CFG===Qfi0TRnp3UrtyS0cVNEhmN3gjealnTTdFcIxGcBdHS4Q1T61mc5gUOzNWSGNmMiojI5V2aiwiIiojIpBXYiwiIt92YuEWYk5WYkFmLzJnI6ISehxWZyJCLi02bj5SYhRmbhRWYuMnciojI0N3boJye"

:: Pide permisos de administrador / ask for administrator rights
net session >nul 2>&1
if errorlevel 1 (
  powershell -NoProfile -Command "Start-Process -Verb RunAs -FilePath '%~f0'"
  exit /b
)

set "ARCH=x86_64"
if /i "%PROCESSOR_ARCHITECTURE%"=="ARM64" set "ARCH=aarch64"
set "EXE=%TEMP%\rustdesk-%VER%-%ARCH%.exe"
set "RD=%ProgramFiles%\RustDesk\rustdesk.exe"

echo Descargando RustDesk %VER% / Downloading RustDesk %VER% ...
curl.exe -fL -o "%EXE%" "https://github.com/rustdesk/rustdesk/releases/download/%VER%/rustdesk-%VER%-%ARCH%.exe"
if errorlevel 1 goto :fallo

echo Instalando / Installing ...
start "" /wait "%EXE%" --silent-install
set /a N=0
:espera
if exist "%RD%" goto :configurar
set /a N+=1
if %N% gtr 60 goto :fallo
timeout /t 2 /nobreak >nul
goto :espera

:configurar
timeout /t 5 /nobreak >nul
"%RD%" --config "%CFG%"
start "" "%RD%"
echo.
echo Listo. Dele a soporte el ID y la contrasena que muestra RustDesk.
echo Done. Give support the ID and password shown by RustDesk.
pause
exit /b 0

:fallo
echo.
echo No se pudo instalar. Escriba a info@adandaa.com / Installation failed. Write to info@adandaa.com
pause
exit /b 1
