echo off

rem !!!!!!!!!!!!!!!! Set Scrubber Exe Name
set EXE_FILE=not_defined
if EXIST ..\..\setup\hpzscr01.exe SET EXE_FILE=..\..\setup\hpzscr01.exe
if EXIST hpzscr01.exe SET EXE_FILE=hpzscr01.exe
if EXIST ..\..\setup\hpzscr40.exe SET EXE_FILE=..\..\setup\hpzscr40.exe
if EXIST hpzscr40.exe SET EXE_FILE=hpzscr40.exe
if "%EXE_FILE%" == "not_defined" goto MISSING_SCRUBBER_EXE

rem !!!!!!!!!!!!!!!! Set Scrubber Dat File Name
set FILE_CDA=not_defined
if EXIST ..\..\setup\hposcr14.dat SET FILE_CDA=hposcr14.dat
if EXIST hposcr14.dat SET FILE_CDA=hposcr14.dat
SET FILE_CDA=hposcr14.dat

set SCRUBBER_DAT_FILE=not_defined

if "%FILE_CDA%" == "not_defined" goto DAT_SCRUBBER
set SCRUBBER_DAT_FILE=%FILE_CDA%
goto DAT_SCRUBBER

:DAT_SCRUBBER
if "%SCRUBBER_DAT_FILE%" == "not_defined" echo "**** Uninstall file not found: hposcr??.dat ****"


rem !!!!!!! If a level is specified, delete all the trigger/tmp files
if not "%1" == "" del %TEMP%\AiO*.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%\AiO1.tmp goto LEVEL2
rem !!!!!!!!!!!!!!!! BEGIN 1st Level
:LEVEL1
echo "***** Executing Level 1 *****"
copy uninstall.bat %TEMP%\AiO1.tmp

start /w %EXE_FILE% -datfile %SCRUBBER_DAT_FILE% -unattended -showdisconnect -nocopytotemp -d MsiUninstaller,TaskUninstaller,RemoveProgramUninstaller,ScannerUninstaller,AiONetworkDriveUninstaller,PrinterUninstaller,DriverUninstaller,ServiceUninstaller,PortUninstaller,RsmUninstaller,RegistryUninstaller,FileUninstaller,MonitorUninstaller,ProcessShutdown,WindowShutdown

goto EXIT
rem !!!!!!!!!!!!!!!! END 1st Level


rem !!!!!!!!!!!!!!!! BEGIN 2nd Level
:LEVEL2
if EXIST %TEMP%\AiO2.tmp goto LEVEL3
copy uninstall.bat %TEMP%\AiO2.tmp
echo "***** Executing Level 2 *****"
start /w %EXE_FILE% -datfile %SCRUBBER_DAT_FILE% -unattended -showdisconnect -nocopytotemp

goto EXIT
rem !!!!!!!!!!!!!!!! END 2nd Level


rem !!!!!!!!!!!!!!!! BEGIN 3rd Level
:LEVEL3
if EXIST %TEMP%\AiO3.tmp goto LEVEL4
copy uninstall.bat %TEMP%\AiO3.tmp
echo "***** Executing Level 3 *****"

start /w %EXE_FILE% -datfile %SCRUBBER_DAT_FILE% -unattended -showdisconnect -nocopytotemp -noreboot

start /w %EXE_FILE% -datfile hpqscr01.dat -unattended -nocopytotemp -noreboot

start /w %EXE_FILE% -datfile hpqbud01.dat -unattended -nocopytotemp -noreboot

start /w %EXE_FILE% -datfile hpqbud05.dat -unattended -nocopytotemp -noreboot

start /w %EXE_FILE% -datfile hpqbud06.dat -unattended -nocopytotemp -noreboot

start /w %EXE_FILE% -datfile hpqbud11.dat -unattended -nocopytotemp -noreboot

start /w %EXE_FILE% -datfile hpqbud17.dat -unattended -nocopytotemp -noreboot

start %EXE_FILE% -datfile hpqhsc01.dat -unattended -nocopytotemp -forcereboot

goto EXIT
rem !!!!!!!!!!!!!!!! END 3rd Level

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

start /w %EXE_FILE% -datfile %SCRUBBER_DAT_FILE% -unattended -showdisconnect -nocopytotemp -noreboot
	
start /w %EXE_FILE% -datfile hpqscr01.dat -unattended -nocopytotemp -noreboot

start /w %EXE_FILE% -datfile hpqbud01.dat -unattended -nocopytotemp -noreboot

start /w %EXE_FILE% -datfile hpqbud05.dat -unattended -nocopytotemp -noreboot

start /w %EXE_FILE% -datfile hpqbud06.dat -unattended -nocopytotemp -noreboot

start /w %EXE_FILE% -datfile hpqbud11.dat -unattended -nocopytotemp -noreboot

start /w %EXE_FILE% -datfile hpqbud17.dat -unattended -nocopytotemp -noreboot

start /w %EXE_FILE% -datfile hpqhsc01.dat -unattended -nocopytotemp -noreboot
		
start %EXE_FILE% -datfile hposcr3rdp.dat -unattended -nocopytotemp -forcereboot

goto EXIT
rem !!!!!!!!!!!!!!!! END 4th Level


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

:EXIT
