在批处理文件中设置变量 [英] Set variable in batch file

查看:145
本文介绍了在批处理文件中设置变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


1.我正在尝试编写运行某些exe的Windows bat文件,

并将退出代码保存在某些局部变量中.

@echo关闭

开始%〜f1

但是我缺少对本地变量的退出代码分配.


2.我还可以从exe终止收集到bat文件中的本地变量的其他可用详细信息吗?

Stack Trace ...还有其他想法吗?


谢谢

Hi all,


1. I''m trying to write a windows bat file that runs some exe,

and saves it exit code in some local variable.

@echo off

start %~f1

but I''m missing the exit code assignment to the local variable.


2. Are there any other available details I can collect from a exe termination into local variable in a bat file?

Stack Trace ...any other ideas ?


Thanks

推荐答案

当程序终止时,退出代码被分配给特殊变量ERRORLEVEL.

如果参考 [批处理文件参考 [ ^ ]
例如
When a programme terminates the exit code is assigned to the special variable ERRORLEVEL.

if reference[^]

batch files reference[^]
e.g.
@echo off
prog.exe
echo %errorlevel%



请注意,根据提供的参数,START命令可能会调用命令处理器的新副本.如果发生这种情况,则在原始上下文中将无法使用exe的退出代码.



Be aware that the START command, depending on the arguments supplied, may invoke a new copy of the command processor. If that happens the exit code from the exe will be not be available in the original context.

elad2109写道:
elad2109 wrote:

2.还有其他可用的详细信息吗?...

2. Are there any other available details ....



我不知道.

艾伦.



Not that I know of.

Alan.


这篇关于在批处理文件中设置变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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