Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2014
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. using System.Diagnostics;
  2. class Program
  3. {
  4. static void Main()
  5. {
  6. //
  7. // Use Process.Start here.
  8. //
  9. Process.Start("C:\");
  10. }
  11. }
  12.  
  13. using System.Diagnostics;
  14.  
  15. class Program
  16. {
  17. static void Main()
  18. {
  19. LaunchCommandLineApp();
  20. }
  21.  
  22. /// <summary>
  23. /// Launch the legacy application with some options set.
  24. /// </summary>
  25. static void LaunchCommandLineApp()
  26. {
  27. // For the example
  28. const string ex1 = "C:\";
  29. const string ex2 = "C:\Dir";
  30.  
  31. // Use ProcessStartInfo class
  32. ProcessStartInfo startInfo = new ProcessStartInfo();
  33. startInfo.CreateNoWindow = false;
  34. startInfo.UseShellExecute = false;
  35. startInfo.FileName = "dcm2jpg.exe";
  36. startInfo.WindowStyle = ProcessWindowStyle.Hidden;
  37. startInfo.Arguments = "-f j -o "" + ex1 + "" -z 1.0 -s y " + ex2;
  38.  
  39. try
  40. {
  41. // Start the process with the info we specified.
  42. // Call WaitForExit and then the using statement will close.
  43. using (Process exeProcess = Process.Start(startInfo))
  44. {
  45. exeProcess.WaitForExit();
  46. }
  47. }
  48. catch
  49. {
  50. // Log error.
  51. }
  52. }
  53. }
  54.  
  55. //The below mentioned code worked for me.
  56.  
  57. Process process = new Process();
  58. //Specify the working directory.
  59. process.StartInfo.WorkingDirectory = @"E:Source";
  60. process.StartInfo.FileName = "Internet.exe";
  61. // 3 arguments, space separated
  62. // configfile imagefilename ocrfilename
  63. process.StartInfo.Arguments = "Arguments"; //Pass the arguments with delimiters
  64. process.StartInfo.UseShellExecute = false;
  65. process.StartInfo.CreateNoWindow = true;
  66. process.Start();
  67. process.WaitForExit();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement