Search code examples
javajavascriptafter-effects

How to make After Effects quit after passing -r javascript from command line


While passing JavaScript myScript.jsx to After Effects I want After Effects to exit on completion:

"C:\Program Files\Adobe\Adobe After Effects CC\Support Files\AfterFX" -r "C:\Workspaces\MyAEScripts\myScript.jsx"

So the very last line in passed JavaScript myScript.jsx script is:

app.quit();

Regardless of this command After Effects just doesn't want to quit. I have tried to include an

app.exitAfterLaunchAndEval=true;

but that didn't help.

If I would pass the same javaScript but using

AfterEffects.exe -s "here is same javascript ending with; app.quit();"

it exits (quits) beautifully.

I would stay with passing javascript (using -r). But there is a limit on how many characters can be used on a command line in Windows. I need to be able to make After Effects to exit after it is finished running script passed with -r c:/path/to/myJavaScript.jsx.


Solution

  • had the same problem you are describing because the project has changed and the app is waiting for your response on whether to save it or not.

    legendary Dan Ebberts suggests adding:

    app.project.close(CloseOptions.DO_NOT_SAVE_CHANGES);
    app.quit();
    

    works for me