@echo off
chcp 65001 >nul
setlocal enableextensions

set "REG_KEY=HKCU\Software\Microsoft\Windows\CurrentVersion\Run"
set "REG_NAME=MediaDownloader"

echo Removing startup registration...
reg delete "%REG_KEY%" /v "%REG_NAME%" /f >nul 2>&1
if errorlevel 1 (
  echo Nothing was registered.
) else (
  echo [OK] Startup registration removed.
)

echo Stopping the running service (if any)...
for /f "tokens=5" %%P in ('netstat -ano ^| findstr /R /C":8765 "') do (
  taskkill /F /PID %%P >nul 2>&1
)
echo [OK] Done.
pause
endlocal
