Call to external programs with parameters

Many PHP applications call to external utility programs with parameters. The PHP function exec() doesn’t work in very most cases in ExeOutput. There is the HEScript command RunAProgram to replace exec():

For example:

procedure procExecProgram;




In the PHP script, this procedure has to be called by (if in the pre-installed UserMain HEScript):


My observations:

  1. Many PHP scripts call programs with parameters. They should be defined in the second field, such as:


  1. White spaces and backslashes in the path are no problem. Example for a macro call:

RunAProgram(“C:\Map Maker\MMmacro.exe”,“C:\Temp\Temp1.bat”,"",true,"");

  1. Output piping will not work as parameter (at least not for me), such as:
    RunAProgram(“Tasklist”," > C:\Temp\Temp1.txt","",true,""); or
    RunAProgram(“Tasklist”," 2>NUL","",true,"");

Alternatives are required, such as ‘wmic’ in case of ‘Tasklist’:

RunAProgram(“wmic”," /output:…","",true,"");

  1. The display mode of the invoked external program was always a pain, already in the PHP interpreter mode (I guess, this is a Windows shortcoming). I also did not manage to make it work here (more doc at ). Any advice will be appreciated.

(This more documentation than an inquiry. I thought, my findings might be of help for others who face the same challenges as I did.)

I’m trying to do something similar. The following post Calling ipconfig the person was able to redirect the output to a file for reading. He said that using the /C switch is key. I don’t know if that is the answer for this post, but it could help someone.

Also wmic with /output is working for me too. Thanks for this.