@echo off
setlocal
pushd "%~dp0"

rem Remove folders/files that should not exist
set SL_FOLDER=%PUBLIC%\Documents\Elysium\3DxSUITE\Config\SmartLauncher\EX9.1
if exist "%SL_FOLDER%" (
  echo Removing folder "%SL_FOLDER%" ...
  rd /s /q "%SL_FOLDER%"
)
set SC_FOLDER=%PUBLIC%\Documents\Elysium\3DxSUITE\Config\SmartController
if exist "%SC_FOLDER%" (
  echo Removing folder "%SC_FOLDER%" ...
  rd /s /q "%SC_FOLDER%"
)
set EDITOR_FILE=%PUBLIC%\Documents\Elysium\3DxSUITE\Config\Editor\EX9.1\preference.json
if exist "%EDITOR_FILE%" (
  echo Removing file "%EDITOR_FILE%" ...
  del /q "%EDITOR_FILE%"
)

rem Remove files that may affect behavior when upgrading from beta to official
call :REMOVE_LU_FILES SmartLauncher
call :REMOVE_LU_FILES SmartController
call :REMOVE_LU_FILES Editor

set WN_CONFIG_FILE=%PUBLIC%\Documents\Elysium\3DxSUITE\Config\WorkerNode\EX9.1\ServiceConfig.xml
if exist "%WN_CONFIG_FILE%" (
  echo Removing file "%WN_CONFIG_FILE%" ...
  del /q "%WN_CONFIG_FILE%"
)

popd
endlocal
echo Hit any key to finish!
pause > NUL
@echo on
goto :eof

:REMOVE_LU_FILES
set LU_FILE1=%LOCALAPPDATA%\Elysium\3DxSUITE\Config\%1\EX9.1\preference.json
set LU_FILE2=%LOCALAPPDATA%\Elysium\3DxSUITE\Config\%1\EX9.1\user_environment.bat
if exist "%LU_FILE1%" (
  echo Removing file "%LU_FILE1%" ...
  del /q "%LU_FILE1%"
)
if exist "%LU_FILE2%" (
  echo Removing file "%LU_FILE2%" ...
  del /q "%LU_FILE2%"
)
goto :eof
