Windows批处理文件-将环境变量插值到可执行调用中 [英] Windows Batch Files - Interpolate environment variables into executable call

查看:67
本文介绍了Windows批处理文件-将环境变量插值到可执行调用中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉,如果我在另一个线程中忽略了此问题,但是却找不到它(在Internet上或实际上在任何地方)。

Apologies if I overlooked this problem in another thread, but I was unable to find it (here or really anywhere on the internet).

在Windows(XP)中,我可以通过右键单击我的电脑,然后选择 Properties> Advanced> Environment Variables 来设置以下全局环境变量:

In Windows (XP), I have the following global environment variable which I set by right-clicking My Computer, then choosing Properties > Advanced > Environment Variables:

CUSTOM_HOME = c:\some\folder\path

如何将其插入批处理文件中的执行中?我需要将 subfolder\program.exe 附加到此路径,以便获得 c:\some\folder\path\批处理文件中的子文件夹 program.exe 。我尝试类似

How do I interpolate this into an execution within a batch file? I need to "append" subfolder\program.exe to this path so that I get c:\some\folder\path\subfolder\program.exe in the batch file. I try something like

%CUSTOM_HOME%\subfolder\program.exe

但是当我执行批处理文件时,输出仅显示

but when I execute the batch file, the output just shows

> \subfolder\program.exe
> The system cannot find the path specified.

什么是正确的语法,因此 .exe 的完整路径将是

What's the correct syntax so the full path to the .exe will be correct?

推荐答案

这是正确的语法,但是如果custom_home路径包含以下内容,则需要对整个内容加上引号空格。

That is the correct syntax, but you will need to add quotes around the whole thing in case the custom_home path contains spaces.

如果找不到,则意味着全局env变量拼写错误或不可用。您可以在命令行中使用 SET CUSTOM_HOME 进行测试。

If it isn't being found, then that means the global env variable is either misspelled or not available. You can test this at the command line with SET CUSTOM_HOME.

这篇关于Windows批处理文件-将环境变量插值到可执行调用中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆