@echo off

echo Upgrade eTerm system!!!

set WORKDIR=%1
set SLEEP=ping 127.0.0.1 -n

if "%WORKDIR%"=="" set WORKDIR="."
echo Working directory: %WORKDIR%

echo Kill process ...
%SLEEP% 2 > nul
taskkill /F /IM eTerm3.exe
taskkill /F /IM 3in1.exe

echo Copy files ...
%SLEEP% 1 > nul
xcopy /E /H /Y /C %WORKDIR%\UpdateCache\* %WORKDIR%\
if errorlevel 0 rmdir /S /Q %WORKDIR%\UpdateCache

echo Restart eterm ...
start "" "%WORKDIR%\eTerm3.exe"
