rem Example: Call PathEnvAddPath.cmd "%UGII_BASE_DIR%"
rem Example: Call PathEnvAddPath.cmd "%UGII_BASE_DIR%" END
rem 10.06.2025 Opti removed find /c /i "%~1;" find /c /i ";%~1"

 if "%~1" equ "" goto :eof

 set pathEnvAddPathCmd_pathExists=

 :: check if path to add is already in path
 @echo ;%PATH%; | find /c /i ";%~1;" > nul
 if "%errorlevel%" equ "0" set pathEnvAddPathCmd_pathExists=yes

 :: check if path to add is already in path (second try with added backslash)
 @echo ;%PATH%; | find /c /i ";%~1\;" > nul
 if "%errorlevel%" equ "0" set pathEnvAddPathCmd_pathExists=yes

 :: exit if path was found before
 if defined pathEnvAddPathCmd_pathExists goto :EOF

 :: add to path
 if /I "%~2" equ "END" set PATH=%PATH%;%~1
 if /I "%~2" neq "END" set PATH=%~1;%PATH%
