.exe file open through ax

Hi all,

can i open 3rd party .exe file through ax?

if it is possible how?can any know this please tell me?

Use WinAPI::shellExcute

Hai kranthi

u really helped us a lot.Thanks for the solution,

Regards

Kishore and Chakradhar.

If I want to execute that .exe file on server i.e., using a server method and on server not on the client from where the method is called, then how can I achieve this?

I have created a server method. Executed an .exe file in that server method using winShell command but it is still executing on client machine rather on the server machine. Please help me… It’s really urgent [:(]

WinAPI::shellExecute() is bound to client. If you want code that works in server scenarios, you may want to use .NET class System.Diagnostics.Process.

I have written the following code in client method as well as in server method.

CLRObject sysExc;

System.Diagnostics.Process process;

System.Diagnostics.ProcessStartInfo processStartInfo;

try

{

processStartInfo = new System.Diagnostics.ProcessStartInfo();

processStartInfo.set_FileName("\\SharedDirectory\ImageMagickBatchProcess.exe");

processStartInfo.set_WorkingDirectory("\\SharedDirectory");

process = new System.Diagnostics.Process();

process.set_StartInfo(processStartInfo);

process.Start();

}

catch (Exception::CLRError)

{

sysExc = ClrInterop::getLastException();

while (sysExc)

{

info(sysExc.get_Message());

sysExc = sysExc.get_InnerException();

}

}

It is executing in client method but not in server method. Also, it is not showing any exception… If I execute the above code in a client method from server machine where AX 2012 AOS is installed, it is executing successfully from there too which means I have installed all the required DLLs on server machine.

What am I missing now? [*-)]

I have written the following code in client method as well as in server method.

CLRObject sysExc;

System.Diagnostics.Process process;

System.Diagnostics.ProcessStartInfo processStartInfo;

try

{

processStartInfo = new System.Diagnostics.ProcessStartInfo();

processStartInfo.set_FileName("\\SharedDirectory\ImageMagickBatchProcess.exe");

processStartInfo.set_WorkingDirectory("\\SharedDirectory");

process = new System.Diagnostics.Process();

process.set_StartInfo(processStartInfo);

process.Start();

}

catch (Exception::CLRError)

{

sysExc = ClrInterop::getLastException();

while (sysExc)

{

info(sysExc.get_Message());

sysExc = sysExc.get_InnerException();

}

}

It is executing in client method but not in server method. Also, it is not showing any exception… If I execute the above code in a client method from server machine where AX 2012 AOS is installed, it is executing successfully from there too which means I have installed all the required DLLs on server machine.

What am I missing now? [*-)]

Is the whole code called or does it crash somewhere in the middle? If all code runs, it’s possible that the application is called but it ends immediately (by any reason). Try to wait for application exit and examine its exit code.

If this is the whole code you call, I would expect it fail, because you didn’t provide InteropPermissions:

InteropPermission permission = new InteropPermission(InteropKind::ClrInterop);
permission .assert();

You may also have problem with permissions of the AOS account.

Thanks Martin…

My post is approved and published too late. I was successful to execute it.

This way, I am calling a Windows Console application to achieve what can be done right from the Dynamics.

I am using ImageMagick API to convert AI images to JPG to show them in Dynamics. I wished to call ImageMagick API right from X++ code. When I used ImageMagick API in X++ code, Client method was working fine. But it fails if I try to execute the code from server (i.e., using RunOn server property).

To use this API, I need to place ImageMagick required header files, code files and libraries on the machine + I need to install GhostScript software on the machine.

Now, if I would call ImageMagick API from client method, all of the client machines will need these files which is not a feasible solution.

I have installed the above mentioned files and software on the server + placed ImageMagick assembly file in Client \ Bin folder, Server \ \ Bin folder and VSAssemblies folder. But, it is still not executing on server method. I have also used the above two statements to assert permissions which you have mentioned. It always gives the same error about missing DLLs.

I don’t know much about ImageMagick, but I think that your .NET wrapper (e.g. if you use libraries from ImageMagick.NET project) uses 32-bit version, so it can’t be loaded into the 64-bit process used by AOS.