Append a directory to PATH Environment Variable in Windows

后端 未结 3 1835
感情败类
感情败类 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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-24 10:39

    setx path c:\whatever
    

    For path setx appends the path specified to the existing path. You don't specify the existing paths, only the new one. It also won't add a path twice.

    Here's something I use

    %windir%\system32\setx path %~sdp0 > "%temp%\filter.tmp"
    

    The redirection hides error messages if I try and add twice. See the call /? command if you don't know what %~sdp0 is

提交回复
热议问题