- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddPath.cmd
More file actions
Latest commit
24 lines (16 loc) · 549 Bytes
/
Copy pathAddPath.cmd
File metadata and controls
24 lines (16 loc) · 549 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
ifnotexist"%~1" (
echo Error: "%~1" doesn't exist
goto :EOF
)
RegQuery HKCU\Environment /v Path|findstr /I "%~1 >nul
if%ErrorLevel%gtr0 (
echo Adding "%~1" to path list
) else (
echo Error: "%~1" already in the PATH list
goto :EOF
)
RegQuery HKCU\Environment /v Path>env.tmp
for /f "tokens=2,* delims= "%%ain (env.tmp) dosetAllButFirst=%%b
Reg Add HKCU\Environment /f /v Path /t REG_EXPAND_SZ /d "%AllButFirst%;%~1
del env.tmp
rem echo REG ADD HKCU\Environment /f /v Path /t REG_EXPAND_SZ /d "%AllButFirst%;%~1