@echo off setlocal EnableExtensions EnableDelayedExpansion @REM Abstrakt v6 silent install script (prod) @REM Fetches the current version from prod.yml, downloads the installer, and installs silently. @REM Prod is a per-machine install -> requires Administrator. Self-elevates if needed. @REM @REM To deliver to customers: rename this file to install-abstrakt.bat and email it. @REM The script self-elevates via UAC, so customers just double-click it. @REM ======== Step 0: Self-elevate to Administrator ======== net session >nul 2>&1 if %errorlevel% neq 0 ( echo Re-launching with Administrator privileges... powershell -NoProfile -Command "Start-Process -FilePath '%~f0' -Verb RunAs" exit /b ) set "CHANNEL=prod" set "BASE_URL=https://storage.googleapis.com/abstrakt-electron-download/AbstraktAppV6/windows/prod" set "INSTALL_DIR=%ProgramFiles%\Abstrakt" set "V5_LEGACY_DIR=!ProgramFiles(x86)!\ABSTRAKT" @REM ======== Step 1: Detect version from prod.yml ======== set "YML_PATH=%TEMP%\abstrakt-%CHANNEL%.yml" echo [1/6] Fetching version... curl -L --fail --silent "%BASE_URL%/%CHANNEL%.yml" -o "%YML_PATH%" if errorlevel 1 ( echo ERROR: Could not fetch %CHANNEL%.yml. Check internet access. goto end ) for /f "tokens=2" %%V in ('findstr /i "^version:" "%YML_PATH%"') do set "VERSION=%%V" del "%YML_PATH%" >nul 2>&1 if not defined VERSION ( echo ERROR: Could not parse version from %CHANNEL%.yml. goto end ) echo [1/6] Detected version: %VERSION% @REM ======== Step 2: Download installer ======== set "INSTALLER_FILENAME=abstrakt-%VERSION%-x64.exe" set "INSTALLER_PATH=%USERPROFILE%\Downloads\%INSTALLER_FILENAME%" echo [2/6] Downloading %INSTALLER_FILENAME%... curl -L --fail --progress-bar "%BASE_URL%/%INSTALLER_FILENAME%" -o "%INSTALLER_PATH%" if errorlevel 1 ( echo ERROR: Download failed. goto end ) echo [2/6] Download complete. @REM ======== Step 3: Pre-install cleanup ======== echo [3/6] Stopping Abstrakt processes... taskkill /IM "Abstrakt.exe" /T /F >nul 2>&1 taskkill /IM "monitor.exe" /T /F >nul 2>&1 net stop AbstraktCrashMonitor >nul 2>&1 echo [3/6] Removing v5 registry entries... reg delete "HKLM\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\{FBD09369-33D6-40DB-A76B-7AF7DAEEBCC5}_is1" /f >nul 2>&1 reg delete "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall\{FBD09369-33D6-40DB-A76B-7AF7DAEEBCC5}_is1" /f >nul 2>&1 if exist "!V5_LEGACY_DIR!" ( echo [3/6] Removing v5 directory... rmdir /S /Q "!V5_LEGACY_DIR!" >nul 2>&1 echo [3/6] Removing v5... 100%% ) @REM Remove v5 shortcuts del "%PUBLIC%\Desktop\ABSTRAKT.lnk" >nul 2>&1 del "%USERPROFILE%\Desktop\ABSTRAKT.lnk" >nul 2>&1 del "%APPDATA%\Microsoft\Windows\Start Menu\Programs\ABSTRAKT.lnk" >nul 2>&1 if exist "%ProgramData%\Microsoft\Windows\Start Menu\Programs\ABSTRAKT" ( rmdir /S /Q "%ProgramData%\Microsoft\Windows\Start Menu\Programs\ABSTRAKT" >nul 2>&1 ) @REM ======== Step 4: Run silent installer ======== echo [4/6] Installing Abstrakt v6... set "PS_INSTALL=%TEMP%\abstrakt-install-progress.ps1" ( echo $proc = Start-Process '%INSTALLER_PATH%' -ArgumentList '/S','/allusers' -PassThru echo $elapsed = 0 echo while ^(-not $proc.HasExited^) { echo Start-Sleep -Milliseconds 500 echo $elapsed += 500 echo $pct = [math]::Min^([math]::Round^($elapsed/120000*95^), 95^) echo Write-Host "`r[4/6] Installing... $pct%%" -NoNewline echo } echo Write-Host "`r[4/6] Installing... 100%%" ) > "!PS_INSTALL!" powershell -NoProfile -ExecutionPolicy Bypass -File "!PS_INSTALL!" del "!PS_INSTALL!" >nul 2>&1 echo [4/6] Installer exit code: %errorlevel% @REM ======== Step 5: Verify installation ======== echo [5/6] Verifying installation... if exist "%INSTALL_DIR%\Abstrakt.exe" ( echo [5/6] Install verified: %INSTALL_DIR%\Abstrakt.exe ) else ( echo WARNING: Abstrakt.exe not found at %INSTALL_DIR%. Installer may have failed. ) @REM ======== Step 6: Clean up installer file ======== echo [6/6] Cleaning up... if exist "%INSTALLER_PATH%" ( del "%INSTALLER_PATH%" >nul 2>&1 ) echo [6/6] Done. :end