Problem executing an external program

Hi everyone,

I’m having a big trouble with a development described in this post.

I am trying to find other solutions to the issue, and one of them is to reate an exe file that does all the conversions. I cerated the exe file, and when I execuet it with the powershell, it work perfectly.

The next step is to run the exe from NAV, and I’m doing this:

path := 'C:\Users\sein.admin2\Documents\RubricaeApp\RubricaeApp.exe';
CLEAR(process);
process := process.Process;
process.StartInfo.UseShellExecute := FALSE;
process.StartInfo.FileName :=path;
process.StartInfo.Arguments := '';
process.StartInfo.CreateNoWindow := TRUE;
process.Start();
process.WaitForExit();

But when I execute, I see this error:

rubri.png

And in the event viewer:

Am I missing any parameter, or doing something wrong?

Thank you very much

Can you try moving you exe file to a location that is not under you user name. Ex. C:\temp and insure that NAV service account have acces to that folder?

It worked, really appreciated!!!

And one question, may be it’s a crazy rhing, but. is it possible to get the return value from the executable?

For example, if in the “Main” I return a string instead of “void”, can I get that value?

Thanks again

i auto-answer mysefl:

process := process.Process;
process.StartInfo.UseShellExecute := FALSE;
process.StartInfo.FileName :=path;
process.StartInfo.Arguments := 'FSR1709885.pdf Z://';
process.StartInfo.CreateNoWindow := TRUE;
process.StartInfo.RedirectStandardOutput := TRUE;
process.Start();
StreamReader := process.StandardOutput;
output := StreamReader.ReadToEnd;
process.WaitForExit();

Great thanks for sharing your code, this will help others :slight_smile: