windows - 更改以从环境变量 PATH 中删除路径

标签 windows command-line command command-prompt

我正在尝试使用命令行实现来更改 PATH 环境变量以删除路径,因此我不必在一堆机器上手动删除它。

我找到了这个,但我似乎无法让它工作:

%Path:str1=str2%

str1 是路径,str2 是 null,我不确定如何在命令行上将它设置为 null。

如果有其他方法,我很乐意尝试。

最佳答案

I have found this, which I can't seem to get it to work: %Path:str1=str2% str1 is the path and str2 is null, which I'm not sure how to set it to null on the command line.

不确定为什么这对您不起作用,但这里有一个确实有效的示例(至少在 Windows XP 上)。

set path=%path:c:\windows\system32;=%

这将删除“c:\windows\system32;”从路径变量。确保你有 ; 最后,否则它可能会部分删除一些其他路径。

请记住,这只会影响命令提示符的当前实例。如果您退出或在不同的命令提示符下工作,您对环境变量所做的任何更改都将丢失。

关于windows - 更改以从环境变量 PATH 中删除路径,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3072423/

相关文章:

windows - 有什么方法可以在您自己的应用程序中使用 Windows 本地化数据吗?

ruby - 为什么部分符号 (§) 无法正确读取,具体取决于它的创建位置?

java - 如何为 .jar 命令行脚本创建别名?

python - 将Windows上的python脚本交叉编译为linux可执行文件

windows - 为什么 Linux git 在 Windows WSL 中运行并在 NTFS 文件系统上运行时不创建适当的 Windows 符号链接(symbolic link)?

python3 --version 显示 "NameError: name ' python 3' is not defined"

linux - 如何使用 Jenkins shell 命令复制文件但不包括某些目录

wpf - 如何触发特定按钮事件的 ViewModel 命令

windows - 在代码管理菜单中恢复visual studio code中删除的文件

perl - 每三次出现的字符串加倍