@echo off
REM ============================================================
REM  Mixer plugin installer  (Windows VST3)
REM
REM  Double-click this file. It asks for administrator rights
REM  once (the Windows "Yes" prompt), then copies the Mixer.vst3
REM  bundle sitting next to it into the system VST3 folder.
REM  Only the previous Mixer.vst3 is replaced; nothing else.
REM ============================================================
setlocal enableextensions

REM --- self-elevate to admin (needed to write Program Files) ---
net session >nul 2>&1
if %errorlevel% neq 0 (
  echo Requesting administrator rights...
  powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs"
  exit /b
)

set "SRC=%~dp0Mixer.vst3"
set "DST=C:\Program Files\Common Files\VST3\Mixer.vst3"

REM --- guard: a running DAW locks the .vst3 and the copy fails silently ---
tasklist 2>nul | find /i "Ableton" >nul
if %errorlevel%==0 (
  echo.
  echo  Close Ableton Live completely first - it locks the plugin file.
  echo.
  pause
  exit /b 1
)

if not exist "%SRC%" (
  echo.
  echo  Could not find "Mixer.vst3" next to this installer.
  echo  Unzip the WHOLE download, then run Install-Mixer.cmd from inside it.
  echo.
  pause
  exit /b 1
)

echo.
echo  Installing Mixer plugin...
echo     from: %SRC%
echo     to:   %DST%
echo.

robocopy "%SRC%" "%DST%" /MIR /R:1 /W:1 /NJH /NJS /NDL /NFL /NP >nul
if %errorlevel% geq 8 (
  echo  Install FAILED ^(robocopy code %errorlevel%^). Try closing your DAW and re-running.
  pause
  exit /b 1
)

echo  Done. Open your DAW and rescan plugins - look for "Mixer" ^(VST3^).
echo.
pause
