| 1 |
@echo off |
| 2 |
|
| 3 |
:: installation path can be passed as argument |
| 4 |
if [%1]==[] ( |
| 5 |
set "installpath=%ProgramFiles%\Environment Modules" |
| 6 |
) else ( |
| 7 |
set "installpath=%1" |
| 8 |
) |
| 9 |
|
| 10 |
:: create installation directory |
| 11 |
md "%installpath%" |
| 12 |
:: quit if directory not created |
| 13 |
if not exist "%installpath%" ( exit /b 1 ) |
| 14 |
|
| 15 |
:: install files |
| 16 |
xcopy /Y /S /F "%~dp0\*" "%installpath%\" |
| 17 |
:: quit on error |
| 18 |
if errorlevel 1 ( exit /b 2 ) |
| 19 |
|
| 20 |
:: add bin directory to system path if not done yet |
| 21 |
set "binpath=%installpath%\bin" |
| 22 |
set FIND=%SYSTEMROOT%\system32\find |
| 23 |
echo %PATH% | %FIND% /i "%binpath:"=%">nul || set "NEWPATH=%binpath%;%PATH%" |
| 24 |
if not "%NEWPATH%" == "" ( |
| 25 |
set "PATH=%NEWPATH%" |
| 26 |
setx /M PATH "%NEWPATH%" |
| 27 |
) |
| 28 |
if errorlevel 1 ( exit /b 3 ) |
| 29 |
|
| 30 |
:: vim:set tabstop=3 shiftwidth=3 expandtab autoindent: |