Suppose I have some commands in a bat file :

echo 1
copy existingFile1 c:
echo 2
copy existingFile1 notExistingDrive:
echo 3
attrib -r attrib notExistingFile

Those are just demos of commands that contains successful commands and also "not-ran-to-completion" return codes.

Visualization :

enter image description here


Is there any way I can get an indication that at least one operation has not-ran-to-completion ?

psuedo :

do something1
do something2
do something3
if noErrorsAll(something1,something2,something3)
 do something4

NB I prefer not to check everytime "if exists".There can be other halts than "not-exists"


1 Answer 1


Redirect/Append the STDERR from each command to (e.g.) log.txt, then read the contents or size into a variable and test for empty/zero bytes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.