Click here to Skip to main content
15,889,858 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 27-May-10 12:50pm
v2

1 solution

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%


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 wrote:
2. Are there any other available details ....


Not that I know of.

Alan.
 
Share this answer
 
Comments
elad2109 26-May-10 16:52pm    
"Not that I know of."

How can I make sure. I could find one evnironment list that documents all the attributes.

This errorlevel is considered to be a "DOS" environment variable...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900