IMWS and IMatch 6 - Apps Process Control

Started by Mario, February 09, 2017, 10:30:50 PM

Previous topic - Next topic

Mario

For IMatch 6 apps, I have improved the ability to run external programs.

The BASIC scripting in IMatch only offered the ShellExecute method which allows you to run a program. But you had no way to wait for the program to finish or to somehow access the output.

This is OK if you want to do something like starting Notepad or Office.
But when you want to run external programs which do something and return some data, you were at a loss.
A typical case is to run some Windows command line tool and then display or process the output. Or run a PowerShell script and process the output. Or even a Node.js script... !!!

I have added an endpoint to the embedded IMWS in IMatch which allows you to run a program, wait for it to complete (while your script can do other things!) and capture the error and standard output of the program. This will allow us to do a lot of cool things way beyond what IMatch can do alone. From running Windows tools or external applications to accessing databases and whatnot.

The demo app shows how to do it and how you can start a program (Notepad) without waiting and how to run programs and capture the output.

In this case we see the captured output of the Windows systeminfo command line application.
The script calls IMatch and lets it run the command. IMatch waits for the program to finish and returns the output. The script then displays this output on the HTML page:



The endpoint is /v1/imatch/startprocess and it has the parameters: "executable", "parameters", "wait", "timeout" and "showwindow". Easy to use, very powerful.

Source Code

This is the code which calls IMWS to run the program, waits for it to finish and then displays the result on the HTML page, pre-formatted (Click to enlarge)



I use the free Microsoft Visual Studio Code editor for all the samples. Very cool software (written in JavaScript!). Download link can be found in the IMatch Anywhere Developer Center
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook

ben

QuoteFor IMatch 6 apps, I have improved the ability to run external programs.
Yeah, that sounds great.

So, as i understand it "i can implement the external commands i need (e.g. connect network drive) via a powershell script and then call it from within iMatch. RIght?
Then i will be able to rewrite all of my current scripts.

Thanks a lot Mario, for listening  8) 8) 8)

Mario

Quotei need (e.g. connect network drive) via a powershell script and then call it from within iMatch. RIght?

Yes. You could use PowerShell or whatever. When you can run your script from the command line (with parameters) you can call it from an IMatch script. You can even collect the output from your external script (what you would see on the screen) and then use that in your script. And of course the "exit code" of your external command is also available so you know whether or not it worked.
-- Mario
IMatch Developer
Forum Administrator
http://www.photools.com  -  Contact & Support - Follow me on 𝕏 - Like photools.com on Facebook