web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

How to run an .exe file from AX?

(0) ShareShare
ReportReport
Posted on by 1,385

Hi Friends,

Can anyone tell, how I can run an .exe file in a specified folder from AX? On running that .exe file, it sends a text file (input.txt) and receives another text file (output.txt) from an website.

Also, how I can import few specified columns from the output.txt file to the AX table?

Note: Text files are with fixed field length.

Thanks,

Aarvi

*This post is locked for comments

I have the same question (0)
  • arviax Profile Picture
    1,385 on at
    RE: How to run an .exe file from AX?

    Hai Martin,

    Thanks for your reply !

    Actually what I need to do is: From AX, I need to create one text file named input.txt. Then I need to run an .exe file which send this newly generated input.txt file to a third party website. In return, I will get another text file named output.txt. Once after getting the output.txt file, I need to import that output.txt file to AX table.

    I have done the tasks into 3 sections:

    1. Exporting to input.txt file

    2. Running .exe file

    3. Importing the output.txt file

    (1) and (3) sections are working fine. I need to execute the section (2) from AX itself to get the output.txt file.

    I can also execute the section (2) manually from command prompt. While executing manually, I can run the .exe file which sends input.txt file to third party website and in few seconds I will receive an output.txt file. When I do it manually, I did not find any issue and am getting the output.txt file.

    Moreover in same method only I did the entire task in Microsoft Dynamics NAV to happen automatically. It is working fine !

    Thanks,

    Aarvi.

  • Martin Dráb Profile Picture
    236,116 Most Valuable Professional on at
    RE: How to run an .exe file from AX?

    Still, verify whether the application gets executed or not, otherwise you don't know what problem to solve.

    Ensure that if you run the application manually, you use the same user (and if it's relevant, the same working path). It's not very useful If you prove that other user can execute it.

    Nevertheless you'll likely have to debug the external application - if it supports any logging or tracing, activate it. If it doesn't, your debugging options depend on how the application has been developed and whether you have source code.

  • arviax Profile Picture
    1,385 on at
    RE: How to run an .exe file from AX?

    Thanks Martin for your reply !

    There is no any issue with the other application because I can run the .exe file manually in command prompt  and make it to do its job.

    Also, I am not getting any error.

    Thanks,

    Aarvi

  • Martin Dráb Profile Picture
    236,116 Most Valuable Professional on at
    RE: How to run an .exe file from AX?

    Does the application execute and fails to send the file, or it isn't executed at all?

    In the first case, you probably can't blame AX that some other application doesn't work as expected. By the way, shouldn't you call it with parameters?

    In the second case, don't you get any error? Typically either the file can't be found or the user doesn't have permissions to execute it. Don't forget that AOS typically uses another computer and user than an AX client.

  • arviax Profile Picture
    1,385 on at
    RE: How to run an .exe file from AX?

    Hi Guys,

    Sorry for reopening this topic again. Using below code,

    WinAPI::shellExecute(@"D:\AX\Test\rece1.exe");

    I can able to trigger an .exe in the folder. On trigerring that .exe file, it sends a text file to third party tool. Using the above code, the sending of text file to third party tool is not happening. Why it is so? Am I doing something wrong here.

    Thanks,

    Aarvi.

  • Verified answer
    Community Member Profile Picture
    on at
    RE: How to run an .exe file from AX?

    Well done.. :)

    Please update the our replies as verified answer, so that this question will get closed

  • arviax Profile Picture
    1,385 on at
    RE: How to run an .exe file from AX?

    Hi Dominic,

    It worked !! :-) Thanks a lot for your kind favor.

    Also, I would like to thanks Martin and Nitesh for their replies.

    Regards,

    Aarvi.

  • dolee Profile Picture
    11,279 on at
    RE: How to run an .exe file from AX?

    Hi Aarvi,

    Try WinAPI::shellExecute(@"D:\AX\Test\rece1.exe");

    Also, it looks like you have put the path value at the "parameter" parameter spot. And have "D:\\" as the path instead.  (msdn.microsoft.com/.../winapi.shellexecute.aspx)

    Maybe that's why it's not working.

    Regards,

    Dominic

  • arviax Profile Picture
    1,385 on at
    RE: How to run an .exe file from AX?

    Hi Dominic,

    Thanks a lot for your response. I tried with the below 3 ways.

    1. WinAPI::shellExecute("rece1.exe",@"D:\AX\Test","D:\\","",1);

    2. WinAPI::shellExecute("rece1.exe","D:\\AX\\Test","D:\\","",1);

    3. WinAPI::shellExecute("rece1.exe","D:\AX\Test","D:\\","",1);

    But still I am getting the same error.

    Thanks,

    Aarvi.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: How to run an .exe file from AX?

    Hi Aarvi,

    Please follow Dominic...

    that is the solution, Please validate

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Andrés Arias – Community Spotlight

We are honored to recognize Andrés Arias as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Community Member Profile Picture

Community Member 4

#2
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#2
Guy Terry Profile Picture

Guy Terry 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans