Archi Forum

Archi Plug-ins => jArchi => Topic started by: Xavier Mayeur on November 08, 2019, 15:19:45 PM

Title: #jarchi - how to run a system command inside a script
Post by: Xavier Mayeur on November 08, 2019, 15:19:45 PM
Hello,

Is it any possibility to run a system command inside a jarchi script, like invoking an external program ?

Thanks
Title: Re: #jarchi - how to run a system command inside a script
Post by: Thomas Rischbeck (ITMC.ch) on March 12, 2020, 22:07:16 PM
Dear all - I'm also looking for an answer to this. Can I call a .exe file on a Windows system directly from an Archi script? Kind regards, Thomas.
Title: Re: #jarchi - how to run a system command inside a script
Post by: Jean-Baptiste Sarrodie on March 13, 2020, 18:51:06 PM
Hi,

Short answer: no

Long answer: jArchi doesn't expose this feature through its API, but jArchi is based on Nashorn which is a JAVA based implementation of Javascript with some extensions. One of these extensions is the ability to use Java classes from JS, so it should be possible to run a system command through Java through JS.

Regards,

JB
Title: Re: #jarchi - how to run a system command inside a script
Post by: Phil Beauvoir on March 14, 2020, 10:02:08 AM
// Launch Notepad on Windows from a jArchi script
var runtime = Java.type("java.lang.Runtime").getRuntime();
runtime.exec("notepad.exe");