Hello experts! I was wondering if you can help guide me in trying to run an exe file (.net) I wrote from within NAV. First of, where is the best place to store this exe file? Should I store it in the APPLICATIONPATH\addins folder? If so, does this mean I have to distribute this exe file in each RTC workstation?
Secondly, I am not sure if I am doing this correctly. I am using System.Diagnostics.Process to run this program from within my codeunit. see below.
....
CLEAR(process);
process := process.Process();
process.StartInfo.UseShellExecute := FALSE;
process.StartInfo.FileName := ConvertProgPath;
process.StartInfo.Arguments := InputXMLPath + ' -xsl ' + XSLTPath + ' -output ' + OutputFilePath;
process.StartInfo.CreateNoWindow :=TRUE;
process.Start();
process.WaitForExit(); //tells Nav to wait for the program to close
But it doesn't seem to work. I am erroring out. it says it doesn't know where the file is. I stored the exe file in the c:\program files\Microsoft dynamics nav\70\service\addins folder. But when I check if it exists, it says it doesn't. see below code snippet whereby it will error out.
ConvertPDFPath := APPLICATIONPATH + 'addins';
ConvertProgPath := ConvertPDFPath + '\myprogram.exe';
IF File.EXISTS(ConvertProgPath) THEN
message('%1 EXISTS!',ConvertProgPath)
ELSE
ERROR('%1 DOES NOT EXIST!',ConvertProgPath);
But If I run the program using the start-run (outside of nav) it works!
Thoughts?
*This post is locked for comments
Hi!
I use next construction, where Process is System.Diagnostics.Process dotnet variable:
It's a codeunit which runs by job queue and takes file name and arguments from job queue entry parameter string (they separate by ; symbol). RunOnClient property of dotnet variable should be = No in this case.
Also you can use universal function with path and attributes parameters for running any app:
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156