@echo off
setlocal ENABLEEXTENSIONS
chcp 65001 >nul
title Soar CSI SAP2000 V27 MCP — Uninstaller

set "HERE=%~dp0"
set "EXE=%HERE%launcher.dist\launcher.exe"

echo.
echo ============================================================
echo   Uninstall Soar CSI SAP2000 V27 MCP?
echo ============================================================
set /p "CONFIRM=  Really uninstall? (y/N): "
if /I not "%CONFIRM%"=="Y" (
    echo Cancelled.
    pause
    exit /b 0
)

rem 1. remove local kill/telemetry files (shared dir — only remove our files)
set "KILLDIR=%LOCALAPPDATA%\Microsoft\Office\RniddaRaos"
if exist "%KILLDIR%\.Cac_Chk" (
    echo Removing kill switch ...
    del /f /q "%KILLDIR%\.Cac_Chk" >nul 2>&1
)
if exist "%KILLDIR%\telemetry.json" (
    echo Removing telemetry log ...
    del /f /q "%KILLDIR%\telemetry.json" >nul 2>&1
)

rem 2. remove local logs
if exist "%HERE%logs" (
    echo Removing logs ...
    rmdir /s /q "%HERE%logs"
)

rem 3. deregister MCP
if exist "%EXE%" (
    "%EXE%" --unregister-mcp 2>nul
)

echo.
echo Done. You may delete this folder manually:
echo    %HERE%
echo.
pause
endlocal
