Remove unwanted path name from %path% variable via batch

前端 未结 4 1583
青春惊慌失措
青春惊慌失措 2020-12-01 05:15

Scope: Windows XP or newer Tools: Batch script

I need to be able to remove an unneeded path name from the system %PATH% variable. I know how to add a new path name

4条回答
  •  有刺的猬
    2020-12-01 05:59

    This removes the substring C:\Program Files (x86)\Git\bin; from the PATH string and re-assigns:

    set PATH=%PATH:C:\Program Files (x86)\Git\bin;=%
    

    You might use this to see the change:

    echo %PATH:C:\Program Files (x86)\Git\bin;=% | tr ; \n
    

    Note: be exact on the substring. It's case-sensitive and slash-sensitive.

    If you need to make it a persistent change use setx instead of set and open another console for changes to take effect.

    setx /M PATH "%PATH:C:\Program Files (x86)\Git\bin;=%"
    

提交回复
热议问题