Skip to main content
Inspiring
April 23, 2024
Question

Execute external application with arguments

  • April 23, 2024
  • 4 replies
  • 506 views

Hi,

 

Using Extendscript, how do you execute an external executable with arguments?

 

var myFile = new File("Path to app/app.exe 'arg1' 'arg2'"):

myFile.execute();

 

It doesn't seem to be supported.

 

Thanx

 

tm

 

This topic has been closed for replies.

4 replies

Legend
April 24, 2024

If you don't mind technology hopping, you can take advantage of InDesign's VBscript:

ExtendScript >> VBScript >> Windows Script Host >> app.exe

E.g. to show a file in Explorer (that would be the external executable).

 

app.doScript(
"CreateObject(\"WScript.Shell\").Run \"explorer /n,/e,/select,"+f.fsName+"\"",ScriptLanguage.visualBasic);

 

I wrote this for CS3 and haven't tested it in a while.

 

Otherwise, your File() could be a shell script or alike that passes on the parameters. Likely that would involve ugly terminal windows, though.

rob day
Community Expert
Community Expert
April 23, 2024

Hi @tmmls , Do you mean you want to open a file in another Adobe application? If that‘s the case you would have to use a BridgeTalk object as @John D Herzog  suggests.

John D Herzog
Inspiring
April 23, 2024

Possibly with bridgetalk, although I think that is specifically for Adobe products.

If you are on an apple machine, it might be possible by calling an applescript that then calls the executable.

Robert at ID-Tasker
Legend
April 23, 2024

File() isn't for executing other applications.

 

https://www.google.com/search?client=firefox-b-d&q=javascript+execute+exe+with+arguments

 

Or maybe it is possible to use File():

https://www.ps-scripts.com/viewtopic.php?p=138643&sid=be944028500c9f098ea14b19c48ebe77#p138643

 

Sorry, I'm not JS guy.