@echo off
setlocal EnableExtensions

set "SCRIPT_DIR=%~dp0"
set "INSTALL_DIR=%LOCALAPPDATA%\BEANalyzer UltraPro"
set "PROJECT_SRC=%SCRIPT_DIR%BEANalyzer_UltraPro"
set "PROJECT_DST=%INSTALL_DIR%\BEANalyzer_UltraPro"
set "LAUNCHER=%INSTALL_DIR%\Run_BEANalyzer_UltraPro.bat"
set "ICON=%PROJECT_DST%\assets\app_icon.png"

echo Installing BEANalyzer UltraPro to:
echo %INSTALL_DIR%
echo.

if not exist "%INSTALL_DIR%" mkdir "%INSTALL_DIR%"
if exist "%PROJECT_DST%" rmdir /s /q "%PROJECT_DST%"
xcopy "%PROJECT_SRC%" "%PROJECT_DST%\" /E /I /Y >nul

copy "%SCRIPT_DIR%Run_BEANalyzer_UltraPro.bat" "%LAUNCHER%" >nul

powershell -NoProfile -ExecutionPolicy Bypass -Command ^
 "$WshShell = New-Object -ComObject WScript.Shell; " ^
 "$Desktop = [Environment]::GetFolderPath('Desktop'); " ^
 "$StartMenu = Join-Path $env:APPDATA 'Microsoft\Windows\Start Menu\Programs'; " ^
 "$Shortcut1 = $WshShell.CreateShortcut((Join-Path $Desktop 'BEANalyzer UltraPro.lnk')); " ^
 "$Shortcut1.TargetPath = '%LAUNCHER%'; " ^
 "$Shortcut1.WorkingDirectory = '%INSTALL_DIR%'; " ^
 "$Shortcut1.Save(); " ^
 "$Shortcut2 = $WshShell.CreateShortcut((Join-Path $StartMenu 'BEANalyzer UltraPro.lnk')); " ^
 "$Shortcut2.TargetPath = '%LAUNCHER%'; " ^
 "$Shortcut2.WorkingDirectory = '%INSTALL_DIR%'; " ^
 "$Shortcut2.Save(); "

echo.
echo Installed. You can open BEANalyzer UltraPro from:
echo - Desktop shortcut
echo - Start Menu
echo.
echo First launch may take a while because it creates the Python venv and installs requirements.
pause
endlocal
