@ECHO OFF
CD %~dp0bin
ECHO Turn on the printer, and connect the printer and computer via USB cable.
ECHO Proceed to the next after connected the printer.
ECHO If you want to cancel the installation, close this window and click cancel button of the installer window.
ECHO --
ECHO If your PC is connected to the internet, there is the possibility that the installer needs some minutes to find the printer.
ECHO If you disconnect the PC and the internet, the printer searching will complete shortly.
SETLOCAL ENABLEDELAYEDEXPANSION

SET /A COUNT=0
SET /A BITS=0

REM set start time
SET T=%TIME: =0%
SET H=%T:~0,2%
SET M=%T:~3,2%
SET S=%T:~6,2%
SET /A H=1%H%-100
SET /A M=1%M%-100
SET /A S=1%S%-100  

ECHO --
:LOOP
.\S2245PnP.exe

REM set end time
SET T1=%TIME: =0%
SET H1=%T1:~0,2%
SET M1=%T1:~3,2%
SET S1=%T1:~6,2%
SET /A H1=1%H1%-100
SET /A M1=1%M1%-100
SET /A S1=1%S1%-100

REM set pass time
SET /A H2=H1-H
SET /A M2=M1-M
if %M2% LSS 0 set /a H2=H2-1
if %M2% LSS 0 set /a M2=M2+60
SET /a S2=S1-S
if %S2% LSS 0 set /a M2=M2-1
if %S2% LSS 0 set /a S2=S2+60

SET /A COUNT=!COUNT!+1
echo PassTime %H2%:%M2%:%S2%
IF !M2! GEQ 5 (
	GOTO ENDLOOP
)

IF !ERRORLEVEL! NEQ 1 (
	GOTO LOOP
)
:ENDLOOP
ENDLOCAL
REM PAUSE
