@echo off
sc delete SNMPAgent.CPKService
set x="Please, type or copy old path for CPK installation: "
set /p old_path=%x%
echo %old_path%

cd %old_path%/Updater
start UpdaterCPK.exe action:stop
timeout /t 5 /nobreak>nul
taskkill /F /IM UpdaterCPK.exe
start UpdaterCPK.exe action:uninstall 
timeout /t 5 /nobreak>nul
taskkill /F /IM UpdaterCPK.exe
cd %old_path%/CPK
echo %cd%
rem set proc = %cd% and SNMPAgent.exe 
rem echo %proc%
timeout /t 10 /nobreak>nul
SNMPAgent.exe action:stop 1
SNMPAgent.exe action:uninstall 1

echo "Coping files..."
set t_path=%~dp0CPK\cfg\
xcopy "%cd%\cfg\*.*" "%t_path%" /K /H /Y
cd %~dp0
echo "installation..."
call %~dp0\install.bat
echo "installation done"
pause