@ECHO OFF
@CD /D %~dp0
@ECHO Start Updateing.......
@Start "" AVACAST_Setup_5.10.10.39.exe /S
GOTO START_UPDATE

:DONE
@CLS
@ECHO Finish.
@CD /D "C:\Program Files\AVACAST\App"
start "" "AVACAST.exe"
@ECHO Start AVACAST....
CALL:CHECK_AVACAST_RUN
@TIMEOUT 5
@REM @PAUSE
@EXIT

:START_UPDATE
@CALL:CHECK_UNINSTALL_START

:CHECK_LOOP
cls
ECHO Start Update
ECHO Updateing wait.
CALL:CHECK_UNINSTALL_PROCESS
CALL:DELAY

cls 
ECHO Start Update
ECHO Updateing wait..
CALL:CHECK_UNINSTALL_PROCESS
CALL:DELAY

cls 
ECHO Start Update
ECHO Updateing wait...
CALL:CHECK_UNINSTALL_PROCESS
CALL:DELAY

cls 
ECHO Start Update
ECHO Updateing wait....
CALL:CHECK_UNINSTALL_PROCESS
CALL:DELAY

cls 
ECHO Start Update
ECHO Updateing wait.....
CALL:CHECK_UNINSTALL_PROCESS
CALL:DELAY

GOTO CHECK_LOOP

:CHECK_AVACAST_RUN
tasklist | find /i "AVACAST.exe" > nul
IF "%errorlevel%"=="0" (
	GOTO:EOF
)
CALL:DELAY
GOTO CHECK_AVACAST_RUN

:CHECK_UNINSTALL_START
tasklist | find /i "AVACAST_Setup" > nul
IF "%errorlevel%"=="0" (
	GOTO:EOF
)
CALL:DELAY
GOTO CHECK_UNINSTALL_START

:CHECK_UNINSTALL_PROCESS
tasklist | find /i "AVACAST_Setup" > nul
IF "%errorlevel%"=="1" (
	GOTO DONE
)
GOTO:EOF

REM delay 1000ms
:DELAY
ping localhost -n 1 -w 1000 > nul
GOTO:EOF