@echo off
setlocal

@taskkill /F /IM Ones.exe
set desktop_path=%~1
set version=%~2
set "source=%desktop_path%\%version%"
set "temp_path=%cd%\app_old_version"

xcopy "%desktop_path%\*" "%temp_path%\" /E /Y /C /I
powershell -Command "Expand-Archive -Path '%desktop_path%\update.zip' -DestinationPath '%source%'"

if %errorlevel% neq 0 (
    xcopy "%temp_path%\*" "%desktop_path%\" /E /Y /C /I
) else (
    xcopy "%source%\*" "%desktop_path%" /E /Y /C /I
)

start "" "%desktop_path%\Ones.exe"

endlocal
