8
Feb
2012
DOS: Capture return values from commands
By Eric Downing. Filed in Scripting, Utilities, Windows |When I am writing build automation scripts, there are times that I have to insure that the previous command completed
with no errors. I have found that ERRORLEVEL gets filled in with the return value from a command.
dir %1 if (%ERRORLEVEL%) == (0) echo Found File: %1 if (%ERRORLEVEL%) == (1) echo Missing File: %1
So if you save the previous in a file and run the command with one (1) argument, it will display the output of the dir command
but also print either “Found file: