@echo off
if "%1"=="purge" goto purge

cls
echo.
echo.
echo.
echo WARNING: this process will uninstall the core Libronix Digital Library System
echo files from your computer. Your Libronix resources and licenses will 
echo not be removed. 
echo.
echo Type Ctrl+C to cancel and answer Y, or
pause

rem first time, copy self to temp folder and run from there
copy PurgeLDLS.bat %temp% > nul

rem launch copy of self
%temp%\PurgeLDLS.bat purge

rem finished
goto done

:purge

rem get proper path to msiexec.exe, make command line
if "%OS%"=="Windows_NT" goto WindowsNT
set MsiExecPath=start /wait "%windir%\System\msiexec.exe"
goto continue

rem use local environment variables
:WindowsNT
setlocal
set MsiExecPath=start /wait "" "%windir%\System32\msiexec.exe"

:continue

rem Libronix Update:
echo Uninstalling Libronix Update...
%MsiExecPath% /qb /x "{5F81DD9B-6A2F-11D4-903E-00E0293397B7}"

rem Common System Files:
echo Uninstalling Common System Files...
%MsiExecPath% /qb /x "{5F81DD89-6A2F-11D4-903E-00E0293397B7}"

rem Libronix Digital Library System:
echo Uninstalling Libronix Digital Library System...
%MsiExecPath% /qb /x "{5F81DD92-6A2F-11D4-903E-00E0293397B7}"

rem Libronix DLS Application:
echo Uninstalling Libronix DLS Application...
%MsiExecPath% /qb /x "{5F81DD97-6A2F-11D4-903E-00E0293397B7}"

rem Libronix DLS Shortcuts:
echo Uninstalling Libronix DLS Shortcuts...
%MsiExecPath% /qb /x "{CA0AF735-4583-413E-897F-E91A237EE2E1}"

rem OEB Resource Driver:
echo Uninstalling OEB Resource Driver...
%MsiExecPath% /qb /x "{19991EAD-C273-47EB-87E8-0D274925230B}"

rem PDF Resource Driver:
echo Uninstalling PDF Resource Driver...
%MsiExecPath% /qb /x "{5F81DDA3-6A2F-11D4-903E-00E0293397B7}"

rem LLS Resource Driver:
echo Uninstalling LLS Resource Driver...
%MsiExecPath% /qb /x "{5F81DD9F-6A2F-11D4-903E-00E0293397B7}"

rem Bible Data Type System Files:
echo Uninstalling Bible Data Type System Files...
%MsiExecPath% /qb /x "{5F81DD84-6A2F-11D4-903E-00E0293397B7}"

rem Sentence Diagramming:
echo Uninstalling Sentence Diagramming...
%MsiExecPath% /qb /x "{A0EFB06D-0C7C-4A85-B1D3-65AF82536A7B}"

rem Graphical Query Editor:
echo Uninstalling Graphical Query Editor...
%MsiExecPath% /qb /x "{CC351B44-5610-43C5-81E6-A2C760CB0A20}"

rem Batch Update:
echo Batch Update...
%MsiExecPath% /qb /x "{72CB5335-6D2A-4207-B811-6CB6C6925039}"

rem Z 39.50 Library:
echo Z 39.50 Library...
%MsiExecPath% /qb /x "{E53A24DC-F90E-4372-937C-77E23DE0932B}"

rem Video Resource Driver:
echo Video Resource Driver...
%MsiExecPath% /qb /x "{0E16D716-ECAC-4881-ABB5-5017ACBDB2D7}"

rem end local environment variable usage
if "%OS%"=="Windows_NT" endlocal

rem remove environment variable
if not "%OS%"=="Windows_NT" set MsiExecPath=

echo.
echo.
echo Uninstall complete.
echo.

:done
