calling another programing langauging from AX 2012

Hi All,

Is there any way to execute (call) powershell scripts from x++ coding ?

Regards,

Darshan.

You could call powershell.exe from WinAPI::shellExecute().

Not sure if that would be a great idea though. Depends on what you’re doing. If you could re-create the PowerShell logic in X++, you’d probably be better off doing that, in most cases.

Powershell is actually a Windows application - you can call it like this: powershell.exe -File MyScript.ps1 or powershell.exe -Command {…}. And you surely can call other applications from AX, e.g. using WinAPI::shellExecute() and System.Diagnostic.Process (through .NET Interop). You’ll find examples of both on the internet.

Nevertheless calling additional process is relatively expensive and it’s often difficult to handle errors (if you use System.Diagnostic.Process, you can at least subscribe to events such as ErrorDataReceived). If you can avoid the external process (e.g. by using a direct API), do it.

Thanks for your reply …

Please don’t forget to mark the useful reply (or replies) as the verified solution.