This commit is contained in:
unknown
2025-12-07 11:38:36 -08:00
parent 56c9d9711a
commit a20d620bf9

View File

@@ -14,20 +14,30 @@ set "SELF=%~f0"
set "TEMP_UNINSTALL=%TEMP%\%APP_NAME%_uninstall.cmd"
:: ---------------------------------------
echo.
echo ========================================================
echo %APP_NAME% — Uninstaller (Secure & Verified Execution)
echo ========================================================
echo Running from: %SELF%
echo.
:: ---------------------------------------
:: SELF-RELAUNCH FROM TEMP
:: SELF-RELAUNCH FROM TEMP (SAFER DESIGN)
:: ---------------------------------------
if /i not "%SELF%"=="%TEMP_UNINSTALL%" (
echo Copying uninstaller to temp and relaunching...
echo Preparing safe removal environment...
echo Copying uninstaller to TEMP: %TEMP_UNINSTALL%
copy "%SELF%" "%TEMP_UNINSTALL%" >nul
echo Starting temporary uninstaller...
start "" cmd /c ""%TEMP_UNINSTALL%" "%SCRIPT_DIR%""
echo Relaunching installer from safe location...
start "" "%TEMP_UNINSTALL%" "%SCRIPT_DIR%"
echo Cleaning handoff...
exit /b
)
:: Now running from TEMP with the original install path
:: At this point, the script runs safely from temp
if "%~1"=="" (
echo [ERROR] Install directory argument missing.
echo [ERROR] Install directory missing — cannot continue.
pause
exit /b 1
)
@@ -35,17 +45,32 @@ set "REAL_INSTALL_DIR=%~1"
echo.
echo ========================================
echo Uninstalling %APP_NAME%
echo Uninstalling %APP_NAME%
echo ========================================
echo.
cd ..
choice /M "Proceed with uninstall?" /C YN
if errorlevel 2 exit /b
cd /d "%REAL_INSTALL_DIR%\.."
:: ---------------------------------------
:: KILL PROCESSES
:: KILL PROCESSES (POLITE FIRST)
:: ---------------------------------------
taskkill /IM "%APP_NAME%.exe" /F >nul 2>&1
taskkill /IM "python.exe" /F >nul 2>&1
echo.
echo Checking for running program instances...
tasklist | find /i "%APP_NAME%.exe" >nul && (
echo %APP_NAME%.exe is currently running.
choice /M "Terminate it to continue?" /C YN
if errorlevel 1 taskkill /IM "%APP_NAME%.exe" /F >nul 2>&1
)
tasklist | find /i "python.exe" >nul && (
echo Python is active and may be linked to the app.
choice /M "Close python.exe automatically?" /C YN
if errorlevel 1 taskkill /IM "python.exe" /F >nul 2>&1
)
:: ---------------------------------------
:: PROCESS .installed PACKAGES
@@ -54,24 +79,26 @@ set "REMOVE_MINIFORGE="
set "SCOOP_PRESENT="
if exist "%INSTALLED_LOG%" (
echo Reading .installed list...
echo.
echo Reading .installed packages list...
for /f "usebackq delims=" %%A in ("%INSTALLED_LOG%") do (
set "ITEM=%%A"
if "!ITEM!"=="" (continue)
if /i "!ITEM!"=="Miniforge3" (
set "REMOVE_MINIFORGE=1"
echo Miniforge3 will be removed manually...
echo Marked Miniforge3 for removal...
continue
)
if /i "!ITEM!"=="scoop" (
set "SCOOP_PRESENT=1"
echo Scoop uninstall will be performed at the very end...
echo Scoop presence detected — will remove at end...
continue
)
echo Uninstalling !ITEM! via Scoop...
echo Uninstalling package using Scoop: !ITEM!
scoop uninstall "!ITEM!" >nul 2>&1
)
)
@@ -81,6 +108,7 @@ if exist "%INSTALLED_LOG%" (
:: ---------------------------------------
if defined REMOVE_MINIFORGE (
if exist "%MINIFORGE_PATH%" (
echo.
echo Removing Miniforge3: %MINIFORGE_PATH%
rd /s /q "%MINIFORGE_PATH%" >nul 2>&1
)
@@ -90,17 +118,18 @@ if defined REMOVE_MINIFORGE (
:: DEFERRED SCOOP UNINSTALL
:: ---------------------------------------
if defined SCOOP_PRESENT (
echo Scheduling Scoop removal in background...
start /b "" cmd /c "ping 127.0.0.1 -n 3 >nul & scoop uninstall scoop >nul 2>&1 & rd /s /q "%USERPROFILE%\scoop" >nul 2>&1"
echo.
echo Removing Scoop and cleanup...
start "" cmd /c "ping 127.0.0.1 -n 3 >nul & scoop uninstall scoop >nul 2>&1 & rd /s /q "%USERPROFILE%\scoop" >nul 2>&1"
)
:: ---------------------------------------
:: REMOVE SHORTCUTS AND REGISTRY
:: ---------------------------------------
echo Removing start menu shortcut...
if exist "%STARTMENU_DIR%" rd /s /q "%STARTMENU_DIR%" >nul 2>&1
echo.
echo Removing Menu entries & Desktop shortcuts...
echo Removing desktop shortcut...
if exist "%STARTMENU_DIR%" rd /s /q "%STARTMENU_DIR%" >nul 2>&1
if exist "%DESKTOP_LNK%" del /q "%DESKTOP_LNK%" >nul 2>&1
reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\ebook2audiobook" /f >nul 2>&1
@@ -108,17 +137,21 @@ reg delete "HKCU\Software\Microsoft\Windows\CurrentVersion\Uninstall\ebook2audio
:: ---------------------------------------
:: DELETE THE ACTUAL APP FOLDER
:: ---------------------------------------
echo Removing application folder: %REAL_INSTALL_DIR%
echo.
echo Removing application directory:
echo %REAL_INSTALL_DIR%
rd /s /q "%REAL_INSTALL_DIR%" >nul 2>&1
:: ---------------------------------------
:: CLEAN UP SELF COPY
:: DELETE SELF COPY & EXIT
:: ---------------------------------------
echo ===================
echo Uninstall complete.
echo.
echo ============================
echo Uninstallation complete.
echo ============================
echo Cleaning temporary uninstaller...
del "%TEMP_UNINSTALL%" >nul 2>&1"
del "%TEMP_UNINSTALL%" >nul 2>&1
timeout /t 2 >nul
exit /b