This installer was built with InstallForge, a free open-source program.
This is the shell command called by the installer:
SETX MAVEN_HOME "<installpath>" & SETX M2_HOME "<installpath>" & REG QUERY "HKCU\Environment" /v PATH & IF ERRORLEVEL 1 (SETX PATH "<installpath>\bin") ELSE FOR /F "usebackq tokens=2*" %a IN (`REG QUERY "HKCU\Environment" /v PATH`) DO ( SETX PATH "%b;<installpath>\bin")
The second part (after the 2nd &) is used to update or create the PATH value for the local user. This code is adapted from https://stackoverflow.com/a/45566845. The "2>nul" code prevents an error message from the installer about "this may not have installed correctly", which is actually due to the preceding code -- which is a test if a local user PATH variable exists.
The JAVA_HOME variable is set by a .bat file in the "install" folder which has the following code:
SETX MAVEN_HOME "<installpath>" & SETX M2_HOME "<installpath>" & REG QUERY "HKCU\Environment" /v PATH & IF ERRORLEVEL 1 (SETX PATH "<installpath>\bin") ELSE FOR /F "usebackq tokens=2*" %a IN (`REG QUERY "HKCU\Environment" /v PATH`) DO ( SETX PATH "%b;<installpath>\bin")
The second part (after the 2nd &) is used to update or create the PATH value for the local user. This code is adapted from https://stackoverflow.com/a/45566845. The "2>nul" code prevents an error message from the installer about "this may not have installed correctly", which is actually due to the preceding code -- which is a test if a local user PATH variable exists.
The JAVA_HOME variable is set by a .bat file in the "install" folder which has the following code:
::- code adapted from https://stackoverflow.com/a/25249886 and https://stackoverflow.com/a/25103599 ::- Test for the registry location SET VALUE=CurrentVersion SET KEY_1="HKLM\SOFTWARE\JavaSoft\Java Development Kit" SET KEY_2=HKLM\SOFTWARE\JavaSoft\JDK SET REG_1=reg.exe SET REG_2="C:\Windows\sysnative\reg.exe" SET REG_3="C:\Windows\syswow64\reg.exe" SET KEY=%KEY_1% SET REG=%REG_1% %REG% QUERY %KEY% /v %VALUE% 2>nul IF %ERRORLEVEL% EQU 0 GOTO _set_value SET KEY=%KEY_2% SET REG=%REG_1% %REG% QUERY %KEY% /v %VALUE% 2>nul IF %ERRORLEVEL% EQU 0 GOTO _set_value ::- %REG_2% is for 64-bit installations, using "C:\Windows\sysnative" SET KEY=%KEY_1% SET REG=%REG_2% %REG% QUERY %KEY% /v %VALUE% 2>nul IF %ERRORLEVEL% EQU 0 GOTO _set_value SET KEY=%KEY_2% SET REG=%REG_2% %REG% QUERY %KEY% /v %VALUE% 2>nul IF %ERRORLEVEL% EQU 0 GOTO _set_value ::- %REG_3% is for 32-bit installations on a 64-bit system, using "C:\Windows\syswow64" SET KEY=%KEY_1% SET REG=%REG_3% %REG% QUERY %KEY% /v %VALUE% 2>nul IF %ERRORLEVEL% EQU 0 GOTO _set_value SET KEY=%KEY_2% SET REG=%REG_3% %REG% QUERY %KEY% /v %VALUE% 2>nul IF %ERRORLEVEL% EQU 0 GOTO _set_value :_set_value FOR /F "tokens=2,*" %%a IN ('%REG% QUERY %KEY% /v %VALUE%') DO ( SET JDK_VERSION=%%b ) SET KEY=%KEY%\%JDK_VERSION% SET VALUE=JavaHome FOR /F "tokens=2,*" %%a IN ('%REG% QUERY %KEY% /v %VALUE%') DO ( SET JAVAHOME=%%b ) SETX JAVA_HOME "%JAVAHOME%" ::- Here is yet another way to access the 64-bit registry from a 32-bit installer: ::- C:\Windows\sysnative\WindowsPowerShell\v1.0\powershell.exe "$JDKregkey='HKLM:\SOFTWARE\JavaSoft\Java Development Kit'; If (-NOT (Test-Path $JDKregkey)) {$JDKregkey='HKLM:\SOFTWARE\JavaSoft\JDK'}; $version=(gp $JDKregkey).CurrentVersion; $javahome=(gp $JDKregkey/$version).JavaHome; SETX JAVA_HOME $javahome;" ::- this ps command identifies a 32-bit or 64-bit shell (it detects a 4 bit or 8 bit process): [IntPtr]::size ::- code adapted from https://stackoverflow.com/a/44602323 and https://stackoverflow.com/a/8588982/1691651
This project is maintained by John Pratt.