我需要存储一个值(时间戳)并稍后在批处理文件中检索它。因此,我在 SO 中搜索了有关如何存储持久变量的答案并找到了 setx。
我是这样使用的:
C:\tmp>setx TIME_VAR %time%
SUCCESS: Specified value was saved.
但是当我尝试用 echo 打印它时,它不存在:
C:\tmp>echo TIME_VAR
TIME_VAR
C:\tmp>echo %TIME_VAR%
%TIME_VAR%
如何取回我的储值?
最佳答案
来自文档 (setx/?
)
Because SETX writes variables to the master environment in the registry, edits will only take effect when a new command window is opened - they do not affect the current CMD or PowerShell session.
关于windows - 使用 setx 后如何检索值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24059311/