@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 ******************** Executing Level4 CleanUP *********************
echo This cleanup utility will remove the HP Photosmart Essential and the
echo HP product drivers, and 3rd. Party applications. 
echo Use this utility to remove software if you have a
echo problem using the software and would like to reinstall the software.
echo.
echo Use this LEVEL 4 cleanup if LEVEL 3 cleanup utility did not fix the problem 
echo and you continue to experience software problems with your HP Deskjet
echo.
echo LEVEL 4 is the most comprehensive cleanup level and 
echo will remove the HP product drivers, HP Photosmart Essential 
echo and all HP components installed with your HP Deskjet device
echo ********************************************************************
echo.
echo If you chose to UNINSTALL, Please do the following...
echo 1. Unplug the USB cable from the back of your HP Deskjet device
echo 2. After the cleanup finishes, restart your computer and wait for Windows 
echo    to start
echo 3. Eject and re-insert the software CD that came with your HP Deskjet 
echo    device to start the installation
echo 4. Follow the on-screen instructions to finish the installation
echo 5. Try printing a document to confirm functionality
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 Photosmart Essential
start /wait ..\..\setup\hpzscr01.exe -datfile hpqbud13.dat -unattended -nocopytotemp -noreboot
	
REM UNINSTALL Imaging Device Function
start /wait ..\..\setup\hpzscr01.exe -datfile hpqbud01.dat -unattended -nocopytotemp -noreboot

REM UNINSTALL Document Viewer
start /wait ..\..\setup\hpzscr01.exe -datfile hpqbud04.dat -unattended -nocopytotemp -noreboot
		
REM UNINSTALL Solution Center & Imaging Support Tool
start /wait ..\..\setup\hpzscr01.exe -datfile hpqbud05.dat -unattended -nocopytotemp -noreboot

REM UNINSTALL Customer Experience
start /wait ..\..\setup\hpzscr01.exe -datfile hpqbud06.dat -unattended -nocopytotemp -noreboot

REM UNINSTALL Remote Print
start /wait ..\..\setup\hpzscr01.exe -datfile hpqbud08.dat -unattended -nocopytotemp -noreboot
	
REM UNINSTALL Extended Capabilities
start /wait ..\..\setup\hpzscr01.exe -datfile hpqhsc01.dat -unattended -nocopytotemp -noreboot

REM UNINSTALL HP Software Update
start /wait ..\..\setup\hpzmsi01.exe -u {7BB3DC99-71DA-4FCB-B0ED-ACA161DBCA4B}

REM UNINSTALL HP SUPPLY
start /wait ..\..\setup\hpzmsi01.exe -u {FE9B929E-3BAF-40B1-BFFC-3A078ABAA0C8}

REM UNINSTALL HP SMART WEB PRINTING
start /wait ..\..\setup\hpzmsi01.exe -u {2D1F2124-29E6-460A-B140-E9DF3BC594CE}

REM UNINSTALL HP Fontana Deskjet & Photosmart Series		
start /wait ..\..\setup\hpzscr01.exe -datfile %SCRUBBER_DAT_FILE% -unattended -showdisconnect -nocopytotemp -forcereboot

:END
echo Uninstallation Completed.

:END_QUIT
echo DONE.
pause

:EXIT
