logo

한국어

__CONFIG__.BAT

:: ------------------------------------------------------------------
:: -
:: - 인스톨/언인스톨에 필요한 변수 셋팅
:: -
:: ------------------------------------------------------------------
SET CONFIG_INSTALL_PATH=%CD%\bin
SET CONFIG_REMOVE_KEYWORD="jdk-12.0.2_x64"

__INSTALL__.BAT

:: ------------------------------------------------------------------
:: -
:: - 실행에 필요한 환경변수와 PATH를 영구히 저장한다.
:: -
:: ------------------------------------------------------------------
@ECHO OFF
CLS

:: ------------------------------------------------------------------
:: - 설정파일 읽어오기
:: ------------------------------------------------------------------
CALL __CONFIG__.BAT

SETLOCAL ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
ECHO ##########################################################################
ECHO #
ECHO # installing %CONFIG_REMOVE_KEYWORD% path
ECHO #
ECHO ##########################################################################

REM PATH에서기존에 있던 경로를 제거하고 그대로 적용한다.
SET LINE_STR=%PATH%
SET LINE_STR=%LINE_STR: =#%
SET LINE_STR=%LINE_STR:;= %

FOR %%P IN (%LINE_STR%) DO ECHO Removed: %%P | FIND /I %CONFIG_REMOVE_KEYWORD% || SET NEWPATH_STR=!NEWPATH_STR!;%%P
SET NEWPATH_STR=!NEWPATH_STR:#= !
SET MODIFIED_PATH=!NEWPATH_STR:~1!

ECHO PATH=%MODIFIED_PATH%;%CONFIG_INSTALL_PATH%
SETX PATH "%MODIFIED_PATH%;%CONFIG_INSTALL_PATH%"

:: ------------------------------------------------------------------
:: - 추가 환경변수 설정
:: ------------------------------------------------------------------
SETX JAVA_HOME "%CONFIG_INSTALL_PATH%"
SETX CLASSPATH "%CONFIG_INSTALL_PATH%\lib"

PAUSE

ENDLOCAL
EXIT /B %ERRORLEVEL%

__UNINSTALL__.BAT

:: ------------------------------------------------------------------
:: -
:: - 실행에 필요했던 환경변수와 PATH를 영구히 제거한다.
:: -
:: ------------------------------------------------------------------
@ECHO OFF
CLS

:: ------------------------------------------------------------------
:: - 설정파일 읽어오기
:: ------------------------------------------------------------------
CALL __CONFIG__.BAT

SETLOCAL ENABLEDELAYEDEXPANSION ENABLEEXTENSIONS
ECHO ##########################################################################
ECHO #
ECHO # uninstalling %CONFIG_REMOVE_KEYWORD% path
ECHO #
ECHO ##########################################################################

REM PATH에서기존에 있던 경로를 제거하고 그대로 적용한다.
SET LINE_STR=%PATH%
SET LINE_STR=%LINE_STR: =#%
SET LINE_STR=%LINE_STR:;= %

FOR %%P IN (%LINE_STR%) DO ECHO Removed: %%P | FIND /I %CONFIG_REMOVE_KEYWORD% || SET NEWPATH_STR=!NEWPATH_STR!;%%P
SET NEWPATH_STR=!NEWPATH_STR:#= !
SET MODIFIED_PATH=!NEWPATH_STR:~1!

ECHO PATH=%MODIFIED_PATH%
SETX PATH "%MODIFIED_PATH%"

:: ------------------------------------------------------------------
:: - 추가 환경변수 제거
:: ------------------------------------------------------------------
REG DELETE "HKCU\Environment" /f /v JAVA_HOME
REG DELETE "HKCU\Environment" /f /v CLASSPATH

PAUSE

ENDLOCAL
EXIT /B %ERRORLEVEL%