设置为驱动器后,HOME 变量值末尾出现引号

设置为驱动器后,HOME 变量值末尾出现引号

我最近在服务器上将HOME变量更改为。今天,我注意到一个问题,即进行某些 GIT 调用的 bat 脚本无法运行,因为由于变量的值输出为,连接路径无效。我尝试了以下所有方法,但似乎都无法解决这个问题:C:\HOMEC:"

> setx HOME C:\
SUCCESS: Specified value was saved.

> echo %HOME%
C:"

> setx HOME C:
SUCCESS: Specified value was saved.

> echo %HOME%
C:"

> setx HOME 'C:'
SUCCESS: Specified value was saved.

> echo %HOME%
C:"

> setx HOME "C:"
SUCCESS: Specified value was saved.

> echo %HOME%
C:"

> setx HOMEDRIVE C:
SUCCESS: Specified value was saved.

> echo %HOMEDRIVE%
C:

> setx HOME %HOMEDRIVE%
SUCCESS: Specified value was saved.

> echo %HOME%
C:"

> setx HOME HOMEDRIVE
SUCCESS: Specified value was saved.

> echo %HOME%
C:"    

> echo %HOMEDRIVE%
C:

> setx HOME %SYSTEMDRIVE%
SUCCESS: Specified value was saved.

> echo %HOME%
C:"    

我真的不知道我做错了什么,但我确定这是一件简单的事情。任何帮助都将不胜感激。谢谢!

答案1

我找到了问题所在。此解决方案提到使用设置的变量的更新值setx在脚本/终端会话结束后才可用。我知道这set不是永久性的setx,但我没有意识到setx更新只有在我关闭并打开新的命令提示符后才可用。

相关内容