0

I am trying to work around a bug in an executable that does not return an error code, and I have to run it in a batch.

Using the following on cmd works (/n is to force an error):

"c:\program files\adobe\adobe after effects 2021\support files\aerender.exe" /n | find "ERROR" && exit 32

The problem is that I need to run in a batch with variable arguments, like so.

"c:\Program Files\Adobe\Adobe After Effects 2021\Support Files\aerender.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9

obviously running

"c:\Program Files\Adobe\Adobe After Effects 2021\Support Files\aerender.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9 | find "ERROR" && exit 32

does not work. Is there a way to do this?

Sorry for the noob question Thanks for the help! Cheers!

  • What about using [`%*`](https://ss64.com/nt/syntax-args.html) rather than `%1 %2 %3 …`? And [`find`](https://ss64.com/nt/find.html) is *not* [`findstr`](https://ss64.com/nt/findstr.html)! – aschipfl Nov 17 '21 at 20:27
  • Please describe what happens. It is not obvious that it does not work. – lit Nov 17 '21 at 20:57
  • Thanks guys I am a noob on cmd, I will keep improving, findstr was a typo, I don't need it, it was just in my mind as I was typing, I guess haha. As for the added description, I thought it was a problem with how cmd interprets the batch, but it actually is how backburner, the app that runs the batch, handles it. It interprets | as an argument and passes it to aerender, which turns out as an error. – Bruno Rantin Po Nov 19 '21 at 05:48
  • Try `("app.exe" %1 %2... %9) | find "ERROR" && ...` The parentheses should prevent the application to take `|` as a parameter. (*Maybe* you need a space before the closing parenthesis) – Stephan Nov 19 '21 at 07:38

1 Answers1

0

In case anyone stumbles on a similar problem, I've solved it like so:

"c:\Program Files\Adobe\Adobe After Effects 2021\Support Files\aerender.exe" %1 %2 %3 %4 %5 %6 %7 %8 %9 > temp.txt
find /I "ERROR" temp.txt
if %errorlevel% equ 0 (exit 32) else (exit 0)

It writes the output to a temp file, then searches that temp file for the word ERROR, if it finds it exits with an error code.

There is probably a better way, but this worked for me Cheers

  • Why do you not use `@"C:\Program Files\Adobe\Adobe After Effects 2021\Support Files\aerender.exe" %* | %SystemRoot%\System32\find.exe /I "Error" >nul && exit /B 32 || exit /B 0`? Open a command prompt, run `call /?` and read the output help explaining how to reference batch file arguments with `%*` with referencing all arguments passed to a batch file at once. Read [Single line with multiple commands using Windows batch file](https://stackoverflow.com/a/25344009/3074564) for an explanation of the operators `&&` and `||`. – Mofi Nov 18 '21 at 18:08
  • Thanks for the help! I will definitely improve the code, I am just not familiarized one bit with cmd. The major problem regarding "|" is backburner, I think, which I should've mentioned. It's cmdjob executable interprets it as an argument and passes it to aerender, which turns out as an error. But I will try it again to see if it works like that. Writing on a txt is not a problem because backburner executes on a temp folder an deletes it every task run, but I will definitely try to clean it up! Thanks a lot! – Bruno Rantin Po Nov 19 '21 at 05:41