Why will my After Effects script run from the menu but not from Command Line?

Viewed 15

I'm trying to run a .jsx file I've written from commandline, but it will not work. When I call "C:\Program Files\Adobe\Adobe After Effects 2020\Support Files\AfterFX.exe" -r script.jsx" After Effects opens and quickly closes, without even modifying the project or appearing to do anything. When I click on File > Script > Run Script inside of AE, it works perfectly fine and the project saves. I also added some alerts to my script which trigger when called from the File menu but not from commandline, making it clear that nothing is happening. What's going on here?

1 Answers

The problem was using relative path for script path. Windows only accepts absolute path as valid for aescripts when running from command line.

Command to run on Windows (NOTE: Always use full paths!)

PowerShell: & "C:\Program Files\Adobe\Adobe After Effects 2022\Support Files\AfterFX.exe" -noui -r "C:\Users\Administrator\Desktop\alert.js"

Command Prompt "C:\Program Files\Adobe\Adobe After Effects 2022\Support Files\AfterFX.exe" -noui -r "C:\Users\Administrator\Desktop\alert.js"

NOTE: both scripts are using flags -noui (no ui) and -r (run script)

Related