@echo off
setlocal
cd /d "%~dp0"

net session >nul 2>&1
if %errorlevel% neq 0 (
  echo Requesting administrator privileges...
  powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
  exit /b
)

set "EXE=C:\Rmsys\app\Rmsys.Api.exe"
if not exist "%EXE%" set "EXE=%~dp0app\Rmsys.Api.exe"
if not exist "%EXE%" (
  echo [ERROR] Rmsys.Api.exe not found.
  echo         Looked for C:\Rmsys\app\Rmsys.Api.exe
  echo         Run this file on the server where the system is installed.
  echo.
  pause
  exit /b 1
)

echo.
echo ==================================================
echo   Reset administrator password
echo ==================================================
echo   - The MySQL service must be running
echo   - The web service keeps running, no need to stop it
echo   - A NEW random password will be generated
echo.
echo   Executable: %EXE%
echo.

"%EXE%" --reset-admin

echo.
echo If the password above is shown, sign in and change it immediately in
echo   System and Audit - Accounts
echo.
pause
