64 位操作系统中的环境变量无需重新启动即可识别
我有 Installshiled 脚本,最初将 CATALINA_HOME 定义为环境变量。之后执行使用 CATALINA_HOME 的批处理文件 service.bat 的相同脚本。该文件在执行时显示错误 CATALINA_HOME 未定义正确定义。因为此变量被定义为环境变量并正确指向 Tomcat 目录。我认为系统需要重新启动才能识别环境变量。有什么方法可以定义无需重新启动即可直接工作的环境。我使用的是 64 位 Windows 7。
I have Installshiled script which define CATALINA_HOME as environment Variable initially. same script after that execute the batch file service.bat that is using CATALINA_HOME. this file when executed display the error CATALINA_HOME is not define define correctly. as this variable is defined as environmental VARIABLE and pointing Tomcat Directory Properly. I thing the system require reboot to recognize environment Variables.Is there any way to define Environment that work directly without reboot. I am using 64 bit Windows 7.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可能是错的,但是您正在运行的脚本在启动时会加载环境变量一次,因此您不会在脚本运行时添加任何新的环境变量。
在您的脚本中,如果您只执行批处理文件,它将使用脚本开始时相同的过时环境变量。
我所做的是运行“cmd /k service.bat”,这将启动一个新的 shell(带有更新的环境变量)并运行批处理文件,然后终止。
您不需要在安装之间重新启动。
I may be wrong but the script that you're running loads the env variables once when you start it so you won't get any new env variables added during the runtime of the script.
And in your script, if you just execute the batch file, it will use the same out dated env variables the script started with.
What I do is run 'cmd /k service.bat' This starts a new shell (with the updated env variables) and runs the batch file and terminates afterwards.
You shouldn't need to reboot between your install.