title: AX 2012, How can I execute a .bat script from x++
body: <p>I have been looking around for a way to execute a bat file from my x++ code.<br>
  I have tried this <a href="http://blogs.msdn.com/b/czdaxsup/archive/2009/04/23/how-to-execute-an-external-process-from-a-batch.aspx" rel="nofollow">approach</a>, but when my code gets to <code>process.Start()</code>, nothing further happens.<br>
  Using the <code>WINApi::Shellexecute()</code> is not a possibility for me as i need this to run in batch. Here is the code I'm currently working with: </p>
  
  <pre><code>System.Diagnostics.Process              process;
  System.Diagnostics.ProcessStartInfo     processStartInfo;
  ;
  new InteropPermission(InteropKind::ClrInterop).assert();
  
  process = new System.Diagnostics.Process();
  
  processStartInfo = new System.Diagnostics.ProcessStartInfo();
  processStartInfo.set_FileName(@'‪C:\temp\testbat.bat');
  
  process.set_StartInfo(processStartInfo);
  
  process.Start();
  
  process.WaitForExit();
  
  
  
  process.Close();
  
  info('Done');
  </code></pre>