REM Ultimate RLM floating license server installer
REM Developed by Ahad Mohebbi
@echo Off
cls
echo    Installing the RLM License Server on Microsoft Windows   
echo ============================================================
echo.
REM extract license files...
unzip ./rlm.zip -x -d "%ProgramFiles%"

rem setup rlm service for machine startup...
cd "%ProgramFiles%\rlm"
rlm.exe -install_service -service_name RLM_License_Server -dlog +"%ProgramFiles%\rlm\rlm_lic.dlog" -c "%ProgramFiles%\rlm\solidangle.lic"
start /B rlm.exe -dlog +"%ProgramFiles%\rlm\rlm_lic.dlog"

rem start rlm_lic service
net start RLM_License_Server

REM setup foundry license files...
if not exist "%ProgramData%\The Foundry\RLM" mkdir "%ProgramData%\The Foundry\RLM"
if not exist "%ProgramData%\The Foundry\FLEXlm" mkdir "%ProgramData%\The Foundry\FLEXlm"
if not exist "%ProgramData%\The Foundry\RLM\log" mkdir "%ProgramData%\The Foundry\RLM\log"
if not exist "%ProgramData%\The Foundry\FLEXlm\log" mkdir "%ProgramData%\The Foundry\FLEXlm\log"
COPY "foundry.lic"  "%ProgramData%\The Foundry\RLM"
COPY "foundry.set"  "%ProgramData%\The Foundry\RLM"

REM setup peregrineLabs license files...
if not exist "%ProgramData%\PeregrineLabs/rlm/" mkdir "%ProgramData%\PeregrineLabs/rlm/"
COPY "peregrinel.lic"  "%ProgramData%\PeregrineLabs/rlm/"
COPY "peregrinel.set"  "%ProgramData%\PeregrineLabs/rlm/"

REM setup genarts license files...
if not exist "%ProgramData%\GenArts\rlm" mkdir "%ProgramData%\GenArts\rlm"
del /Q "%ProgramData%\GenArts\rlm\*.*"
COPY "genarts.lic"  "%ProgramData%\GenArts\rlm"
COPY "genarts.set"  "%ProgramData%\GenArts\rlm"

REM setup License environments...
setx fabricinc_LICENSE "5053@localhost"
setx foundry_LICENSE "5053@localhost"
setx genarts_LICENSE "5053@localhost"
setx golaem_LICENSE "5053@localhost"
setx innobright_LICENSE "5053@localhost"
setx mootzoid_LICENSE "5053@localhost"
setx nextlimit_LICENSE "5053@localhost"
setx peregrinel_LICENSE "5053@localhost"
setx redshift_LICENSE "5053@localhost"
setx solidangle_LICENSE "5053@localhost"
setx SFX_LICENSE_SERVER "5053@localhost"
setx RLM_LICENSE "C:\Program Files\rlm"
echo.

echo The RLM License Server successfully installed.
CD %HOMEPATH%
pause
Exit /B 5
