@echo off
setlocal EnableExtensions
title Devon Uninstaller

echo Closing Devon...
taskkill /F /IM Devon.exe /T >nul 2>&1
timeout /t 2 /nobreak >nul

set "UNINSTALL="

if exist "%LOCALAPPDATA%\Programs\Devon\Uninstall Devon.exe" (
  set "UNINSTALL=%LOCALAPPDATA%\Programs\Devon\Uninstall Devon.exe"
)

if not defined UNINSTALL if exist "%LOCALAPPDATA%\Programs\devon\Uninstall Devon.exe" (
  set "UNINSTALL=%LOCALAPPDATA%\Programs\devon\Uninstall Devon.exe"
)

if not defined UNINSTALL (
  for /f "tokens=2*" %%a in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\8f4c2e1a-3b9d-4f6a-a1c2-9d8e7f6a5b4c" /v UninstallString 2^>nul') do (
    set "UNINSTALL=%%b"
  )
)

if not defined UNINSTALL (
  for /f "tokens=2*" %%a in ('reg query "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\ai.devon.desktop" /v UninstallString 2^>nul') do (
    set "UNINSTALL=%%b"
  )
)

if not defined UNINSTALL (
  echo.
  echo Devon is not installed on this computer.
  echo You can also remove it from Windows Settings ^> Apps.
  echo.
  pause
  exit /b 1
)

echo.
echo Running Devon uninstaller...
echo %UNINSTALL%
echo.
start "" /wait %UNINSTALL%
echo.
echo Done.
pause
