Geeks With Blogs
Anish Abslom
| Home |
Is it possible to execute a batch file on an AOS server from a remote AX client?
Answer is yes, provided you have necessary permission for this execution on the server.
Please create a batch file on your AOS server.
Some thing as below for creating a directory on the server.
 
 Insert a command something like this in a .BAT file (batch file) and place any were on the server.
 
Mkdir “c:\test”
 
 
 Copy the following code into your server static method of your class and call this piece of code from a button click on Ax form. Please execute this button click from a remote AX client and see the result . This should execute the batch file on the server and should create a directory called ‘test’ on the root directoryof the server.
 
 
server static void AOS_batch_file_create()
{
boolean b;


System.Diagnostics.Process process;
System.Diagnostics.ProcessStartInfo processStartInfo;
;
b = Global::isRunningOnServer();
infolog.add(0, int2str(b));

new InteropPermission(InteropKind::ClrInterop).assert();
process = new System.Diagnostics.Process();
processStartInfo = new System.Diagnostics.ProcessStartInfo();
processStartInfo.set_FileName("C:\\create_dir.bat"); // batch file path on the AOS server
process.set_StartInfo(processStartInfo);

process.Start();

//process.Refresh();
//process.Close();
//process.WaitForExit();
info("Finished");

}
 
 
Posted on Thursday, May 6, 2010 4:14 AM Dynamics AX | Back to top


Comments on this post: Executing a Batch file from remote Ax client on an AOS server

# re: Executing a Batch file from remote Ax client on an AOS server
Requesting Gravatar...
Thanks for posting this. I found it very helpful recently. I appreciate you sharing this.
Left by Chris Jamison on Jul 28, 2010 7:31 AM

Your comment:
 (will show your gravatar)


Copyright © Anisha | Powered by: GeeksWithBlogs.net