从可执行设置一个变量 [英] Setting a variable from an executable
问题描述
我运行一个批处理文件的可执行文件有两个参数;
I am running an executable in a batch file with two parameters;
CMD / K可执行文件参数1参数2
这将返回我想推出一个字符串。我想不出如何设置这个返回的一个变量,随后在IE浏览器启动。
This returns a string that I want to launch. I can't figure out how to set this return in a variable and subsequently launch it in IE.
任何想法?
推荐答案
您可以使用下列语法来可执行文件的输出捕获到一个变量:
You can use the following syntax to capture the output of your executable into a variable:
FOR /F "tokens=*" %%i in ('%~dp0YOUR_APP.exe') do SET TOOLOUTPUT=%%i
<一个href=\"http://weblogs.asp.net/lorenh/archive/2006/03/24/silly-batch-file-tricks-redirecting-stdout-into-an-evironment-variable-and-dp0.aspx\"相对=nofollow称号=源>来源
然后你可以通过值IE像这样:
then you can pass the value on to IE like so:
START "YOUR_WINDOW_NAME" /MAX /D"C:\Program Files\Internet Explorer\" iexplore %TOOLOUTPUT%
我是否可以认为应用code决定的URL是太复杂,可以在批处理文件直接复制,或源可执行已丢失。如果不是我个人preFER有在批处理文件本身可见的逻辑。
I take it that the application code that determines the url is too complicated to be reproduced in a batch file directly, or the source to the executable has been lost. If not I personally would prefer to have the logic visible in the batch file itself.
这篇关于从可执行设置一个变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!