Call an EXE from Mendix UI?

0
I want to call exe from Mendix. This exe perform posprocessing logic for some file format. I want to provide a GUI for workflow and call this exe within. Is this possible or a way to do it?
asked
2 answers
1

Yes possible with the method Runtime.getRuntime().exec in a custom Java action, where you can open, write and execute the command in cmd.exe, example

 


		//sox audio.wav --channels=1 --bits=16 audio.flac
		Process p = Runtime.getRuntime().exec("cmd /c start "cd C:\\Users\\SK\\Documents\\Mendix\\NativeMobile-main\\sox\\  "
				+ "&& sox" + UUID+".wav --channels=1 --bits=16 "+UUID+".flac"
				+ "&& exit");

 

Additional sources;

https://www.tutorialspoint.com/java/lang/runtime_exec

https://stackoverflow.com/questions/16452964/how-do-i-execute-windows-commands-in-java

...

 

answered
0

Hi

        var process = new java.lang.ProcessBuilder(
            "BIN",
            "ARG0",
            ...,
            "ARG0"
        ).start();
        var is = process.getInputStream();
        var isr = new java.io.InputStreamReader(is);
        var br = new java.io.BufferedReader(isr);
        var line;
        var str_ret='';
        while ((line = br.readLine()) != null) {
          str_ret+=line+'\n';
        }

You might also want to store stdout/stderr and return code in some mendix table

Probably better to build something that can execute shell scripts or batch scripts, and then store that in a table, then you

can edit it at runtime, and additionally set up a scheduling system for your scripts

Processbuilder is slightly different from Sinan’s answer in that the flags are split over the member function varargs section

answered