Windows:无法使用echo显示用户环境变量
我正在查看使用 Windows 控制台命令创建的用户环境变量
reg add "hkcu\environment" /v SARMaster_Server_Name /d %smServer%
该变量名称 SARMaster_Server_Name
可以在 HKCU/Environment
下的注册表中使用正确的值以及通过控制面板的高级系统设置。
但是,当我运行时,
echo %SARMaster_Server_Name%
我得到 %SARMaster_Server_Name%
而不是此环境变量的实际值。我错过了什么?所有其他环境变量(例如 TEMP)都可以回显。
I am looking at a user environment variable created using Windows console command
reg add "hkcu\environment" /v SARMaster_Server_Name /d %smServer%
This variable name SARMaster_Server_Name
can be seen in the registry under HKCU/Environment
with the correct value as well as through the advanced System settings of the Control Panel.
However, when I run
echo %SARMaster_Server_Name%
I get %SARMaster_Server_Name%
instead of the actual value of this environment variable. What did I miss? All other environment variables such as TEMP can be echoed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用正确设置变量
但是,我需要重新启动才能访问该变量。在我的场景中没有帮助的解决方法是从控制面板打开环境变量编辑器,并在使用“reg add”添加变量后单击“确定”。不知何故,此操作注册了新变量,现在可以在新的 CMD 会话上访问该变量。问题是在 XP 上报告的,因此它可能已在 Windows 7 上修复
Variable is being set correctly using
However, I need to restart to be able to access this variable. A workaround, which does not help in my scenario is to open the Environment Variables editor from the Control Panel and click on OK after the variable has been added using "reg add". Somehow, this action registers the new variable which can now be accessed on a new CMD session. Problem is being reported on XP so it may have been fixed on Windows 7 a