@echo off setlocal EnableExtensions EnableDelayedExpansion @REM Abstrakt v6 silent uninstall script (prod) @REM Stops processes, removes the AbstraktCrashMonitor service, runs the NSIS uninstaller, @REM cleans up leftover files and stale registry entries. @REM Prod is a per-machine install -> requires Administrator. Self-elevates if needed. @REM User data at %LOCALAPPDATA%\Abstrakt is preserved (deleteAppDataOnUninstall: false). @REM @REM To deliver to customers: rename to uninstall-abstrakt.bat and email 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 "INSTALL_DIR=%ProgramFiles%\Abstrakt" set "UNINSTALLER=%INSTALL_DIR%\Uninstall Abstrakt.exe" @REM ======== Step 1: Kill any running ABSTRAKT processes ======== taskkill /IM "Abstrakt.exe" /T /F >nul 2>&1 taskkill /IM "monitor.exe" /T /F >nul 2>&1 @REM ======== Step 2: Stop and remove the AbstraktCrashMonitor service ======== net stop AbstraktCrashMonitor >nul 2>&1 sc delete AbstraktCrashMonitor >nul 2>&1 @REM ======== Step 3: Run NSIS uninstaller ======== if exist "%UNINSTALLER%" ( echo Running uninstaller: %UNINSTALLER% @REM /S = silent. _?=path keeps uninstaller pinned to its location (we delete it after). "%UNINSTALLER%" /S _?=%INSTALL_DIR% echo Uninstaller exit code: !errorlevel! timeout /t 2 /nobreak >nul ) else ( echo WARNING: Uninstaller not found at %UNINSTALLER%. Will still attempt cleanup. ) @REM ======== Step 4: Force-delete install folder if anything remains ======== if exist "%INSTALL_DIR%" ( echo Removing leftover install folder: %INSTALL_DIR% rmdir /S /Q "%INSTALL_DIR%" >nul 2>&1 if exist "%INSTALL_DIR%" ( echo WARNING: Could not fully remove %INSTALL_DIR% (some files may be in use). ) ) @REM ======== Step 5: Sweep stale Abstrakt uninstall registry entries ======== @REM Too complex for pure batch -- use PowerShell inline (powershell.exe is on every Windows). powershell -NoProfile -Command "$hives=@('HKCU:\Software\Microsoft\Windows\CurrentVersion\Uninstall','HKLM:\Software\Microsoft\Windows\CurrentVersion\Uninstall','HKLM:\Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall'); foreach($h in $hives){ if(-not(Test-Path $h)){continue}; Get-ChildItem $h | ForEach-Object { $p=Get-ItemProperty $_.PSPath -ErrorAction SilentlyContinue; if($p.DisplayName -imatch 'abstrakt' -and $p.InstallLocation -and -not(Test-Path $p.InstallLocation)){ Write-Host \"Removing stale uninstall entry: $($p.DisplayName) -> $($p.InstallLocation)\"; Remove-Item $_.PSPath -Recurse -Force -ErrorAction SilentlyContinue } } }" @REM ======== Step 6: Verify uninstall ======== if exist "%INSTALL_DIR%\Abstrakt.exe" ( echo WARNING: Abstrakt.exe still present at %INSTALL_DIR%. Uninstall may have failed. ) else ( echo Uninstall verified: %INSTALL_DIR% cleaned up. echo Note: User data at %LOCALAPPDATA%\Abstrakt is preserved. ) :end