Needs to pass Commanline parameters when running another App

Using the procedure, below, the RARtest.exe opens up fine with no commandline parameters, however when using the commandline parameters for the default save directory and most importantly, the -p password option, I get the following error message, that it can’t execute the program with the parameters, thinking that the parameters are part of the program name. I tried it with none, one and both commandline options and only none works.

Rartest.exe is a passworded RAR executable to hold data and document samples. This will keep the password safe from all users and the link to execute this is locked from non registered users.

I will try a few more options and will report back, otherwise, is there another way I can do this?

Thanks,
HawkeyeTX

procedure OpenRARProgram;
var
EbookPath, MyProgram: String;
begin
// Read the path to the folder that contains our ebook .exe
EbookPath := GetGlobalVar(“HEPublicationPath”, “”);
// Construct the path to the .exe file we want to launch.
MyProgram := EbookPath + “Rartest.exe -de:\rartest -pRARtest1”;
// Execute the program!
if not RunAProgram(MyProgram, “”, EbookPath, false, SW_SHOWNORMAL) then
begin
MessageBox("Unable to execute the external program : " + MyProgram, “Ebook Error”, MB_OK+MB_ICONERROR);
exit;
end;
end;

I changed the position of the commandline parameters. It’s working great, as expected.

if not RunAProgram(MyProgram, “-de:\rartest -pRARtest1”, EbookPath, false, SW_SHOWNORMAL) then
begin

If there is a better way or correct way, please let me know.

Thanks,
HawkeyeTX

No, the second parameter is actually the command line parameters that you want to pass to the program. See http://www.htmlexe.com/help/scriptreference.htm

I am having some issues in getting this to work when passing information. I changed it so I could pass the file name. See below.

[size=4]procedure OpenRARProgram;
var
EbookPath, MyProgram: String;
begin
EbookPath := GetGlobalVar(“HEPublicationPath”, “”);
// I want to pass the program name to the function
MyProgram := EbookPath + MyProgram;
if not RunAProgram(MyProgram, “”, EbookPath, false, SW_SHOWNORMAL) then
begin
MessageBox("Unable to execute the external program : " + MyProgram, “Ebook Error”, MB_OK+MB_ICONERROR);
exit;
end; [/size]

This is what I am calling the function with. The full path is not included to the EXE.
href=“hescript://UserMain.OpenRARProgram(RARtest.exe,-dc:\rartest -pRARtest1,Z:\HTMLSamples\WinTest)”

I then changed it by adding the full path
href=“hescript://UserMain.OpenRARProgram(Z:\HTMLSamples\WinTest\RARtest.exe,-dc:\rartest -pRARtest1,Z:\HTMLSamples\WinTest)”

You can see the results from the status bar on the two attachments when hovering over the links. The syntax in the attachments match what is shown if the reference material.

[size=4]function RunAProgram(const Filename, Params, WorkingDir: String; Wait: Boolean; DispWindow: Integer): Boolean;[/size]

I get no errors what so ever, just click and nothing.

Can you show me what I am doing wrong?

Thanks,
HawkeyeTX

When trying to pass just the command line parameter to the function, it opens the EXE but does not use the command line parameters based on the information from http://www.htmlexe.com/help/callscript.htm. The link you gave me, http://www.htmlexe.com/help/scriptreference.htm, has little information on passing parameters.

href=“hescript://UserMain.OpenRARProgram**|**-dc:\rartest -pRARtest1”>Extract the Data for Registered Users

I was used to passing parameters to a function from a different language. Sorry about the confusion.

Is the above syntax correct now or tell me why it is not working?

Thanks,

procedure OpenRARProgram;

is defined without any parameter. So when you call:
“hescript://UserMain.OpenRARProgram|-dc:\rartest -pRARtest1”

it won’t work: “-dc:\rartest -pRARtest1” cannot be passed to the procedure…

I am having major issues with this before I purchase, I cannot get a valid answer on how how to pass a parameter to a function or procedure. I keep being told on what I’m doing is wrong but no real example on what I need to do.

procedure OpenRARProgram;
var
EbookPath, MyProgram: String;
begin
// Read the path to the folder that contains our ebook .exe
EbookPath := GetGlobalVar(“HEPublicationPath”, “”);
// Construct the path to the .exe file we want to launch.
MyProgram := EbookPath + “Rartest.exe”;
// Execute the program!
if not RunAProgram(MyProgram, " -de:\rartest -pRARtest1", EbookPath, false, SW_SHOWNORMAL) then
begin
MessageBox("Unable to execute the external program : " + MyProgram, “Ebook Error”, MB_OK+MB_ICONERROR);
exit;
end;

Response above;

No, the second parameter is actually the command line parameters that you want to pass to the program. See http://www.htmlexe.com/help/scriptreference.htm

Program, procedure or function? According to a recent post to this thread, this is not correct, right?

I try to pass it from a HTML page, but that is not correct either with a “|” , right?

From another post, above.

it won’t work: “-dc:\rartest -pRARtest1” cannot be passed to the procedure…

If I try to pass it from the procedure to the function, with the following;

procedure OpenRARProgram;
var
EbookPath, MyProgram: String;
begin
// Read the path to the folder that contains our ebook .exe
EbookPath := GetGlobalVar(“HEPublicationPath”, “”);
// Construct the path to the .exe file we want to launch.
MyProgram := EbookPath + “Rartest.exe| -de:\rartest -pRARtest1”;
// Execute the program!
if not RunAProgram(MyProgram, “”, EbookPath, false, SW_SHOWNORMAL) then
begin
MessageBox("Unable to execute the external program : " + MyProgram, “Ebook Error”, MB_OK+MB_ICONERROR);
exit;
end;

I get an error and cannot save to the usermain.

Why cannot I get a valid example of a way to pass the parameter to set the destination and password? I get told what is not valid but no examples, and the reference to a page that does not help, http://www.htmlexe.com/help/scriptreference.htm.

Why can’t I be shown how do you pass a information to a procedure or function, -de:\rartest -pRARtest1, without out being referenced to another page?

I cannot be the only one with this issue?

I will be probably be the first, if I cannot follow examples and will admit I cannot follow examples if this is really documented somewhere.

Thanks,
HawkeyeTX

Because the solution is in the page I told you: http://www.htmlexe.com/help/callscript.htm, and you have a sample:

[quote]If your procedure/function uses string parameters (only string parameters!), you can pass them using a | separator.
Syntax: hescript://[scriptname].[functionprocedurename]|param1|param2|…|paramN

Example: hescript://MyScript.ProcedureA|test

Live Demonstration:

We are using a second example. The script procedure in “demo1” is:

procedure MySecondDemo(cond: String);
var
S: String;
begin
S := “first”;
if cond=“2” then S := “second”;
MessageBox(“The " + S + " link was clicked”, “Second Demo”, MB_OK+MB_ICONINFORMATION);
end;

It takes one string parameter.[/quote]

In your case:

procedure OpenRARProgram;
var
EbookPath, MyProgram: String;
begin
// Read the path to the folder that contains our ebook .exe
EbookPath := GetGlobalVar("HEPublicationPath", "");
// Construct the path to the .exe file we want to launch.
MyProgram := EbookPath + "Rartest.exe| -de:\rartest -pRARtest1";
// Execute the program!
if not RunAProgram(MyProgram, "", EbookPath, false, SW_SHOWNORMAL) then
begin
MessageBox("Unable to execute the external program : " + MyProgram, "Ebook Error", MB_OK+MB_ICONERROR);
exit;
end;

you have no parameter in:
procedure OpenRARProgram;

Replace it with procedure OpenRARProgram(para: string);

procedure OpenRARProgram(para: string);
var
EbookPath, MyProgram: String;
begin
// Read the path to the folder that contains our ebook .exe
EbookPath := GetGlobalVar("HEPublicationPath", "");
// Construct the path to the .exe file we want to launch.
MyProgram := EbookPath + "Rartest.exe";
// Execute the program!
if not RunAProgram(MyProgram, para, EbookPath, false, SW_SHOWNORMAL) then
begin
MessageBox("Unable to execute the external program : " + MyProgram, "Ebook Error", MB_OK+MB_ICONERROR);
exit;
end;

Then:
href=“hescript://UserMain.OpenRARProgram|-dc:\rartest -pRARtest1,Z:\HTMLSamples\WinTest” might not properly work: insert this line in the previous code to see what characters are not properly passed to the function:

procedure OpenRARProgram(para: string);
var
EbookPath, MyProgram: String;
begin
// Read the path to the folder that contains our ebook .exe
EbookPath := GetGlobalVar("HEPublicationPath", "");
**ShowMessage(para);**
// Construct the path to the .exe file we want to launch.
MyProgram := EbookPath + "Rartest.exe";
// Execute the program!
if not RunAProgram(MyProgram, para, EbookPath, false, SW_SHOWNORMAL) then
begin
MessageBox("Unable to execute the external program : " + MyProgram, "Ebook Error", MB_OK+MB_ICONERROR);
exit;
end;

Thank you very much for the examples. It makes it very clear where I made the mistakes. I will be testing them shortly.

Thanks again,
HawkeyeTX