我该如何检索使用SETX后的价值? [英] how do I retrieve a value after using setx?
本文介绍了我该如何检索使用SETX后的价值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要存储的值(时间标记),后来在批处理文件检索。因此,我已搜查所以对于如何存储持久性变量,发现SETX答案。
I need to store a value (a time stamp) and retrieve it later in batch files. So I have searched SO for answers on how to store a persistent variable and found setx.
我用它是这样的:
C:\tmp>setx TIME_VAR %time%
SUCCESS: Specified value was saved.
但是,当我试图与它呼应打印它不存在:
But when I try to print it with echo it is not there:
C:\tmp>echo TIME_VAR
TIME_VAR
C:\tmp>echo %TIME_VAR%
%TIME_VAR%
我如何找回我的储值?
How do I retrieve my stored value?
推荐答案
从DOC( SETX /?
)
由于SETX在写入变量主环境
注册表,当一个新的命令窗口的编辑才会生效
打开 - 他们不影响当前CMD或PowerShell会话
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.
这篇关于我该如何检索使用SETX后的价值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文