0

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

Question

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"

Royi Namir
  • 5,888

1 Answers1

0

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.

Red Anne
  • 142