1
0
HID-Tools-Collection/add_to_path.cmd

25 lines
561 B
Batchfile
Raw Normal View History

@echo off
@setlocal
rem cobbled together by https://github.com/nefarius
set MYDIR=%~dp0
pushd "%MYDIR%"
SETLOCAL EnableDelayedExpansion
rem grab current value
for /f "tokens=1,2*" %%a in ('reg query "HKCU\Environment" /v path') do set currentValue=%%c
set newValue=!currentValue!
rem enumerate directories
for /d %%d in (*.*) do (
rem concat previous and new value
set newValue=!newValue!;%MYDIR%%%d
)
rem update new value
reg add "HKCU\Environment" /v Path /t REG_EXPAND_SZ /d "!newValue!" /f 2>nul
echo Added !newValue! to User PATH
popd
endlocal
pause