【问题标题】:Environment variable change made in a batch is not reflecting immediately [duplicate]批处理中的环境变量更改不会立即反映[重复]
【发布时间】:2015-07-08 08:34:50
【问题描述】:

我正在尝试设置以下环境变量,并调用 .exe 文件。这特别采用变量的值并创建元数据文件。

但运行批处理时设置的值仅在我第二次运行时才会反映。有没有办法立即反映环境变量的变化?

以下是示例

setx -m USER_HOME "D:\\user_home"

start "" C:\\sample.exe

【问题讨论】:

  • 在这种情况下,您可能只需要set,而不需要setx

标签: batch-file windows-7


【解决方案1】:

重新启动 explorer.exe 可能就足够了。尝试taskkill /f /im explorer.exe 并在设置变量后使用explorer.exe 重新启动它。

【讨论】:

  • 不,不会影响cmd.exe的运行实例。
猜你喜欢
  • 1970-01-01
  • 2016-04-27
  • 1970-01-01
  • 2011-01-07
  • 2021-12-12
相关资源
最近更新 更多