我有一个肯定有人遇到过的问题,但也许我没有使用正确的搜索词。我希望将命令提示符中的 PATH 变量重置为默认值。所以,例如,我打开一个提示
set PATH=C:\someting\bin;%PATH%
REM do something
set PATH=<original when window was opened>
REM do something else
我看到的两个解决方案:
1.这个笨拙
set ORIPATH=%PATH%
set PATH=C:\someting\bin;%PATH%
REM do something
set PATH=%ORIPATH%
REM do something else
2.单独的cmd
cmd.exe /k
set PATH=C:\someting\bin;%PATH%
REM do something
exit
cmd.exe/k
set PATH=C:\someting_else\bin;%PATH%
REM do something else
exit
这似乎有一个明显的缺点,那就是其他环境设置会丢失。
有没有更好的方法,如果有,是什么?
提前致谢!