Skip to main content
Inspiring
January 21, 2014
Question

AfterFX.exe always returns 1 on the command line

  • January 21, 2014
  • 2 replies
  • 2462 views

I'm trying to script AfterFX.exe to do stuff from a command line process, seemingly like lots of people who use this interface.


I've found that AfterFX.exe (the CC version anyway) always returns 1 to the command shell if the shell waits for it to exit. I would love to use error codes to indicate success or failure but apparently despite documentation (the After Effects Scripting Guide) telling me to set exitCode however I wish... 1 is the return value. Even if exitCode is zero.

Running AfterFX.exe from the command shell directly immediately returns so the return code isn't useful. If you launch it with start /wait (i.e. start "dummy" /wait "C:\Program Files\Adobe\Adobe After Effects CC\Support Files\AfterFX.exe" -r c:\path\to\my.jsx -noui) then the command shell doesn't come back until the app is done. You get this same behavior without the start /wait stuff if AFx is run via batch file (which is actually how I'm using it). As such, the return code is useless.


Does this happen for others, is this as designed (i.e. running After Effects is just an error, lol) or ... ?

Also,

> start "dummy" /wait "C:\Program Files\Adobe\Adobe After Effects CC\Support Files\AfterFX.exe" -s "alert('hello');app.exitCode=88" -noui

> echo %errorlevel%

1

The existence of -noui doesn't seem to affect the return code. The "dummy" bit on the command line is a requirement of start when launching apps with arguments (it's a bit esoteric but it has to be there).

This topic has been closed for replies.

2 replies

Inspiring
June 20, 2019

This did briefly work when changing over to AfterFx.com but it was broken shortly thereafter.

C:\Program Files\Adobe\Adobe After Effects CC 2018\Support Files>afterfx.com -s "app.exitAfterLaunchAndEval = false; alert('hello'); app.exitCode = 0; app.quit();"

Using DXGI: Device: "Intel(R) HD Graphics P630" has dedicated video RAM (MB): 128 and has shared video RAM (MB): 16309 (Total: 16437 MB)

Using DXGI: Device: "Intel(R) HD Graphics P630" has dedicated video RAM (MB): 128 and has shared video RAM (MB): 16309 (Total: 16437 MB)

Unable to read VR Path Registry from C:\Users\tplunket\AppData\Local\openvr\openvrpaths.vrpath

C:\Program Files\Adobe\Adobe After Effects CC 2018\Support Files>echo %ERRORLEVEL%

0

This is a bummer, because I am trying to detect a failure. (After Effects will crash if the 'alert' call isn't in there, and I've found it often crashes if I don't prevent it from automatically exiting but I haven't completely characterized that; hence the exitAfterLaunchAndEval at the beginning and the app.quit at the end.)

This is part of a batch process so the return code is actually important.

(I just noticed that the exitCode I set there is 0, but it does not seem possible to edit the code block after the fact. Feel free to set it to whatever you want and you'll find that 0 is the errorlevel when it completes!)

Participant
May 20, 2015

Hi,

I have the same issue...

Did you find a solution ?

Inspiring
June 16, 2015

Yes, I found that you need to use AfterFX.com instead of AfterFX.exe. I also seem to recall that this is documented in the Extend Script documentation somewhere; not actually called out but the examples all use AfterFX.com.