Test result of application.executeProgram?

I figured I should be able to test the result like this:

var success = application.executeProgram(‘rundll32’, ‘url.dll,FileProtocolHandler’,fileName)

but success = “” after the run.

Is there another way to test this process completion?

The tooltip on application.executeProgram says it does return output…but what :?:

Did you try executing something impossible? This might result in output from which you can determine the error…

@Marc - just trying to run an app using a file that does not exist does nothing. Not sure where to look for feedback in the system since there appears to be no error thrown?

Anyone from Servoy have an understanding of what the return should be from this method / function?

mboegem:
The tooltip on application.executeProgram says it does return output…but what :?:

This is the output of the program you execute (what it returns). Not sure if it throws an exception in any situation (when something goes wrong).

lvostinar:
This is the output of the program you execute (what it returns). Not sure if it throws an exception in any situation (when something goes wrong).

Is there any way to test it for completion Laurian?

Kahuna:

lvostinar:
This is the output of the program you execute (what it returns). Not sure if it throws an exception in any situation (when something goes wrong).

Is there any way to test it for completion Laurian?

If it gets to next statement then it is completed. :) I don’t think will run out of the box (relative paths, no environment variables …). I would say make a bat or run cmd.exe.

lvostinar:
If it gets to next statement then it is completed. :) I don’t think will run out of the box (relative paths, no environment variables …). I would say make a bat or run cmd.exe.

Laurian - two further questions if I may:

  1. When running this method in Developer its obviously accessing my dev PC and so opening the files based on my associations. When run from a remote server - will executeProgram() attempt to open the file on the Client PC or the server - and where will the associations be considered?

  2. If creating a Bat or Cmd file - how would that file be loaded on a Client PC. Would that have to be manually installed on every PC that may be used to access the solution? Or is there some mechanism where we could have Servoy install that file?

I have a situation where a user may connect to the solution from one of many terminals / PC’s. Obviously he would have the WebStart / Web Client links but may not have the possibility to install or modify the particular PC at which he’s working?

Hmm, it will open the program on the PC where the script is executed. Not sure what you want to execute. So, maybe bat file is not a good idea. I think you can send arguments to cmd.exe to tell it what script to execute; also it may work to just specify environment in executeProgram. Just some brief ideas about possible dirrections to take, getting into details would require more investigation.

Thanks for the feedback Laurian

lvostinar:
Not sure what you want to execute. So, maybe bat file is not a good idea. I think you can send arguments to cmd.exe to tell it what script to execute; also it may work to just specify environment in executeProgram.

All I’m doing currently is offering the user a way to open a file (the file string is held in our solution though the file itself is held outside of the solution) based on the file extension - typically, zip, doc, xls etc. I’m not using it to run another program that interacts with my solutions!

lvostinar:
Just some brief ideas about possible dirrections to take, getting into details would require more investigation.

Great thanks Laurian - I assume this is a Servoy created function? If so would it be possible to modify it to show a return value (bool or error code)?

All I’m doing currently is offering the user a way to open a file (the file string is held in our solution though the file itself is held outside of the solution) based on the file extension - typically, zip, doc, xls etc. I’m not using it to run another program that interacts with my solutions!

Then this is for Smart client.

Great thanks Laurian - I assume this is a Servoy created function? If so would it be possible to modify it to show a return value (bool or error code)?

We allready return the output and throw the errors that may occur. If you have a case that doesn’t work well (it doesn’t execute and doesn’t give any feedback or something) please open a case and we’ll have a look if we can improve it.

lvostinar:
If you have a case that doesn’t work well (it doesn’t execute and doesn’t give any feedback or something) please open a case and we’ll have a look if we can improve it.

This is the simple code that I’m testing Laurian - and if it does’nt find the file or the extension is not recognised it returns nothing that I can see!

function open_file()
{
var fileName = forms.documents.doc_file_name
if(utils.stringMiddle(application.getOSName(),1,7) == “Windows”)
{
var success = application.executeProgram(‘rundll32’, ‘url.dll,FileProtocolHandler’,fileName)
application.output(success)
}

}

Console (and var success) is always “” if the execute works or not?

Kahuna:

lvostinar:
If you have a case that doesn’t work well (it doesn’t execute and doesn’t give any feedback or something) please open a case and we’ll have a look if we can improve it.

This is the simple code that I’m testing Laurian - and if it does’nt find the file or the extension is not recognised it returns nothing that I can see!

function open_file()
{
var fileName = forms.documents.doc_file_name
if(utils.stringMiddle(application.getOSName(),1,7) == “Windows”)
{
var success = application.executeProgram(‘rundll32’, ‘url.dll,FileProtocolHandler’,fileName)
application.output(success)
}

}

Console (and var success) is always “” if the execute works or not?

Ok, then please open a case, I don’t see an immediate solution to this. (or maybe others can come up with something)