@echo off

SET choice=a

set SCRUBBER_EXE_FILE=not_defined
if EXIST ..\..\setup\hpzscr01.exe SET SCRUBBER_EXE_FILE=..\..\setup\hpzscr01.exe
if EXIST hpzscr01.exe SET SCRUBBER_EXE_FILE=hpzscr01.exe
if "%SCRUBBER_EXE_FILE%" == "not_defined" goto MISSING_SCRUBBER_EXE

set SCRUBBER_DAT_FILE=not_defined
REM LOOK FOR SCRUBBER DAT FILE OF DJ_SF
if EXIST ..\..\setup\hphscr15.dat SET SCRUBBER_DAT_FILE=hphscr15.dat
if EXIST hphscr15.dat SET SCRUBBER_DAT_FILE=hphscr15.dat

REM LOOK FOR SCRUBBER DAT FILE OF PS_APP
if EXIST ..\..\setup\hphscr16.dat SET SCRUBBER_DAT_FILE=hphscr16.dat
if EXIST hphscr16.dat SET SCRUBBER_DAT_FILE=hphscr16.dat

REM LOOK FOR SCRUBBER DAT FILE OF PS_APP_02
if EXIST ..\..\setup\hphscr17.dat SET SCRUBBER_DAT_FILE=hphscr17.dat
if EXIST hphscr17.dat SET SCRUBBER_DAT_FILE=hphscr17.dat
echo.
echo.
 
if Windows_NT==%OS% GOTO WIN2K_XP
GOTO WIN9x_ME

:WIN2K_XP
echo Press ENTER to continue Uninstalling... 
echo              OR 
echo Press Q followed by ENTER to QUIT Uninstallation

SET /P Choice=

IF /I ‘%choice:~0,1%’==’Q’ GOTO END_QUIT

GOTO DISPLAY

:WIN9x_ME
choice /C:cq Press Q to quit Uninstall OR press C to continue...
if ERRORLEVEL==2 GOTO END_QUIT
if ERRORLEVEL==1 GOTO DISPLAY

GOTO END_QUIT

:MISSING_SCRUBBER_DAT
echo "**** Uninstall file not found: hphscr??.dat ****"
goto EXIT

:MISSING_SCRUBBER_EXE
echo "**** Uninstall file not found: hpzscr01.exe ****"
goto EXIT

:DISPLAY
rem !!!!!!! If a level is specified, delete all the trigger/tmp files
if not "%1" == "" del %TEMP%\PIPS*.tmp

rem !!!!!!! If a level is specified, goto the appropriate level
if "%1" == "1" goto LEVEL1
if "%1" == "2" goto LEVEL2
if "%1" == "3" goto LEVEL3
if "%1" == "4" goto LEVEL4

if EXIST %TEMP%\PIPS1.tmp goto LEVEL2
rem !!!!!!!!!!!!!!!! BEGIN 1st Level
:LEVEL1
echo "***** Executing Level 1 *****"

call Uninstall_L1.bat

copy uninstall.bat %TEMP%\PIPS1.tmp
goto EXIT
rem !!!!!!!!!!!!!!!! END 1st Level

rem !!!!!!!!!!!!!!!! BEGIN 2nd Level
:LEVEL2
if EXIST %TEMP%\PIPS2.tmp goto LEVEL3
echo "***** Executing Level 2 *****"
call Uninstall_L2.bat

copy uninstall.bat %TEMP%\PIPS2.tmp
goto EXIT
rem !!!!!!!!!!!!!!!! END 2nd Level


rem !!!!!!!!!!!!!!!! BEGIN 3rd Level
:LEVEL3
if EXIST %TEMP%\PIPS3.tmp goto LEVEL4
echo "***** Executing Level 3 *****"
call Uninstall_L3.bat

start /wait ..\..\setup\hpzscr01.exe -datfile hpqscr01.dat -unattended -nocopytotemp

copy uninstall.bat %TEMP%\PIPS3.tmp
goto EXIT
rem !!!!!!!!!!!!!!!! END 3rd Level

rem !!!!!!!!!!!!!!!! BEGIN 4th Level
:LEVEL4
echo "***** Executing Level 4 *****"

call Uninstall_L4.bat

rem !!!!!!!!!!!!!!!! END 4th Level

echo DONE.

:EXIT
