Вот часть скрипта (Install.cmd) которым я инсталлирую Far Manager:
Код: @echo off & setlocal enableDelayedExpansion
pushd %~dp0\..
set FarHome=%cd%
popd
pushd %~dp0
:: Environment
set bin=%%FarHome%%\Bin
set arc=%bin%\Arc
set key=HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\Environment
reg add "%key%" /f /v "FarHome" /d "%FarHome%"
for /f "tokens=1,2,*" %%n in ('reg query "%key%" /v "Path"^|find /i "REG_EXPAND_SZ"') do set P=%%p
if "%P%" neq "" (
set P0=%P%
for /f %%c in ('echo %P%^|find /i /c "%bin%"') do if "%%c" equ "0" set P=%bin%;!P!
for /f %%c in ('echo %P%^|find /i /c "%arc%"') do if "%%c" equ "0" set P=%arc%;!P!
)
if "%P%" neq "%P0%" reg add "%key%" /f /v "Path" /t REG_EXPAND_SZ /d "%P%"
"%FarHome%\Bin\nircmd.exe" sysrefresh environment
:: ... censored
popd
endlocal
exit /b