Append a directory to PATH Environment Variable in Windows

后端 未结 3 1836
感情败类
感情败类 2021-01-24 09:47

So, I have this batch file that supposedly appends my script to the path variable

@echo OFF

setx path "%path%;%cd%\\script.py"

But I e

3条回答
  •  滥情空心
    2021-01-24 10:40

    I found the answer here: https://superuser.com/questions/601015/how-to-update-the-path-user-environment-variable-from-command-line

    @echo OFF
    
    
    for /f "skip=2 tokens=3*" %%a in ('reg query HKCU\Environment /v PATH') do (
        if [%%b]==[] (
            setx PATH "%%~a;%cd%"
        ) else (
            setx PATH "%%~a %%~b;%cd%"
        )
    )
    

提交回复
热议问题