How do I call an exe passing Vars or params using EXEOutput for PHP correctly?


#1

Hoping Someone can help me with this I have 2 issues that I will deal with 1 at a time.

Issue #1

The first is that I need to use EXEOutput for PHP to start an external exe file that has a complicated and multiple parameters / switches after the exe file.

for example:

myexefolder\myfile.exe  --param-1=1 --param-2= -differentparamformatvar SOMETHING --param3=3a --differentvar 0 -o http://[email protected]

If I try to call the file using HE SCRIPT as simply:

myexefolder\myfile.exe

It works no problem, but as soon as I add the parameters, it does not start the external application.

Here is the HESCRIPT I have used:

procedure TestExeStartup;

var

EbookPath, MyProgram: String;

begin

EbookPath := GetGlobalVar("HEPublicationPath", "");

MyProgram := EbookPath + "myexefolder\myfile.exe  --param-1=1 --param-2= -differentparamformatvar SOMETHING --param3=3a --differentvar 0 -o http://[email protected]";

RunAProgram(MyProgram, "", EbookPath, false, SW_SHOWNORMAL);
                                                                    
end;

The HESCRIPT is named: “TestingExeScript” and is called via a simple link click from a page where the link is:

<a href="hescript://TestingExeScript.TestExeStartup">Click HERE to START</a>

Any ideas how to get this issue working with the params… It will start the exe fine if I remove the params but I need the params?

Issue #2

Taking the above idea of calling an external exe with params to the next level, I am wondering if it is possible to pass parameters to the HESCRIPTING engine via a link so that the exe parameters could be dynamic based on data in the link. for example:

Instead of my link to call the exe looking like this:

<a href="hescript://TestingExeScript.TestExeStartup">Click HERE to START</a>

Is there a method of calling sort of like this maybe:

<a href="hescript://TestingExeScript.TestExeStartup?file=myexefolder\myfile.exe  --param-1=1 --param-2= -differentparamformatvar SOMETHING --param3=3a --differentvar 0 -o http://[email protected]">Click HERE to START</a>

or with the data URL encoded like this:

<a href="hescript://TestingExeScript.TestExeStartup?file=myexefolder%5Cmyfile.exe%20%20--param-1%3D1%20--param-2%3D%20-differentparamformatvar%20SOMETHING%20--param3%3D3a%20--differentvar%200%20-o%20http%3A%2F%2Fwww.google.com%40google">Click HERE to START</a>

If someone could help me out with this it would be great!


#2

The issue is because you are passing parameters to the wrong argument.
Here is the modified code that should work:

procedure TestExeStartup;

var

EbookPath, MyProgram: String;

begin

EbookPath := GetGlobalVar("HEPublicationPath", "");

MyProgram := EbookPath + "myexefolder\myfile.exe";

RunAProgram(MyProgram, "--param-1=1 --param-2= -differentparamformatvar SOMETHING --param3=3a --differentvar 0 -o http://[email protected]", EbookPath, false, SW_SHOWNORMAL);
                                                                    
end;

Sure, that’s possible and explained in our doc:
http://www.exeoutput.com/help/callscript#using-html-links

hescript://[scriptname].[functionprocedurename]|param1|param2|.....|paramN

Parameters should be encoded as in URLs.


#3

As always thanks for the quick help and support… That is why I have been a customer for so long and have bought your stuff going back so long ago!

One question about issue #2

Would the parameters in the url look like this then:

<a href="hescript://TestingExeScript.TestExeStartup|--param-1%3D1|--differentvar%20datahere|-o%20http%3A%2F%2Fwww.google.com%40google">Click HERE to START</a>

Also is there a limitation on number of params?


#4

The parameters you are passing to the TestExeStartup are not directly passed to the EXE.
To do so, change the code to:

procedure TestExeStartup(MyParams: String);

var

EbookPath, MyProgram: String;

begin

EbookPath := GetGlobalVar("HEPublicationPath", "");

MyProgram := EbookPath + "myexefolder\myfile.exe";

RunAProgram(MyProgram, MyParams, EbookPath, false, SW_SHOWNORMAL);
                                                                    
end;

Then, you can run with:
<a href="hescript://TestingExeScript.TestExeStartup|--param-1=1%20%--XXXX">Click HERE to START</a>
XXXX should be the remaining entire params string you want to pass, properly encoded.


#5

Super… Last question and I have a perfect answer…

If I wanted the EXE Program to be dynamic as well, so I needed to pass 2 params. The first being the EXE path and folder:

"myexefolder\myfile.exe"

and the second being the params after the exe. so:

"--param-1%3D1%20--param-2%3D%20-differentparamformatvar%20SOMETHING%20--param3%3D3a%20--differentvar%200%20-o%20http%3A%2F%2Fwww.google.com%40google"

My link url would look like this:

hescript://TestingExeScript.TestExeStartup |myexefolder%5Cmyfile.exe| -param-1%3D1%20--param-2%3D%20-differentparamformatvar%20SOMETHING%20--param3%3D3a%20--differentvar%200%20-o%20http%3A%2F%2Fwww.google.com%40google

But how do I differentiate between the parms in the Script? How would that work something like this?

procedure TestExeStartup;

var

EbookPath, MyProgram, ExeInput_VAR1, PamaInput_VAR2: String;

begin

EbookPath := GetGlobalVar("HEPublicationPath", "");

MyProgram := EbookPath + "" + ExeInput_VAR1 +"";

RunAProgram(MyProgram, "" + PamaInput_VAR2 + "", EbookPath, false, SW_SHOWNORMAL);
                                                                
end;

Would this work?


#6

Sure, if you pass arguments to the function (which you forgot in your code):

procedure TestExeStartup(ExeInput_VAR1, PamaInput_VAR2: String);

var

EbookPath, MyProgram: String;

begin

EbookPath := GetGlobalVar("HEPublicationPath", "");

MyProgram := EbookPath + ExeInput_VAR1;

RunAProgram(MyProgram, PamaInput_VAR2, EbookPath, false, SW_SHOWNORMAL);
                                                                
end;

#7

Thanks bro… going to purchase my copy of PHP exe later today. I have now bought HTMLEXE and I am not sure if you were also the guy that mad ASP EXE back in like 2003, But your service level is awesome, your software works great and has made me a lot of money over the years… Thank you so much for the great products and service!


#8

You’re welcome :wink: