• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to launch a batch file from an After Effects script?

New Here ,
May 16, 2014 May 16, 2014

Copy link to clipboard

Copied

Hello everyone,

my Os is Windows 7 Entreprise

I have written this A.E. script

var myFile= new File("C:/myBatch.bat");
myFile.execute();

When I double clic in my file browser on myBatch.bat, it opens cmd.exe and the batch is correctly executed

BUT, if I launch it from an After Effects script as written above, the command window opens and closes at once and nothing happens.

The script above works for any kind of applications (.doc, .xls,..) but not with .bat.  WHY?

Many thanks,
TOPICS
Scripting

Views

2.0K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 16, 2014 May 16, 2014

Copy link to clipboard

Copied

Hi jobo3553,

Maybe you can try to run the batch script like this,

runBatchScript = function(BAT_PATH) {

  cmd = "cmd.exe /c \"\"" + BAT_PATH + "\" \"";

  return system.callSystem(cmd);

  }

runBatchScript("D:/Desktop/test.bat");

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 19, 2014 May 19, 2014

Copy link to clipboard

Copied

Hi Zhiqing_Li,

Many thanks for your contribution. Unfortunately, it does not work on my system. Does it on yours?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 21, 2014 May 21, 2014

Copy link to clipboard

Copied

Yes, it works on my computer. The idea is running the bat file from cmd

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
May 26, 2014 May 26, 2014

Copy link to clipboard

Copied

Hi Zhiqing,

GOOD NEWS. It works now. Even with a slightly simpler script as the one below (on Windows).

runBatchScript = function(BAT_PATH) {

  cmd = "cmd.exe /c " + BAT_PATH ;

  return system.callSystem(cmd);

  }

runBatchScript("D:/Desktop/test.bat");


The reason of the issue I had before was that in my batch I was calling configuration text files or commands using relative path names. It only works when double-clicking on the batch file inside the file explorer but using After Effects scripting it is necessary to refer to command or files inside the batch using ABSOLUTE file path (c:\folder1\folder2\textFile.txt etc.)

Many thanks again for your precious help.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 26, 2014 May 26, 2014

Copy link to clipboard

Copied

Congratulation

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 18, 2017 Apr 18, 2017

Copy link to clipboard

Copied

LATEST

Hi jobo5533,

I have tried the same command suggested by you. But I get error saying that "Unable to access jar file filename.jar ".

my batch file content is

java -jar ./filename.jar ./

I have the filename.jar in the exact same path as the batch file. Do you have any idea?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines