I do not see an error in your code. I wrote a small program that outputs its arguments to the console
static void Main (string[] args) { foreach (string s in args) Console.WriteLine(s); Console.Read();
and then I put it in C:, which is the name of the application "PrintingArgs.exe", so I wrote another one that runs the first:
Process p = new Process(); p.StartInfo.FileName = "C:\\PrintingArgs.exe"; p.StartInfo.Arguments = "1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18"; p.Start();
this gives me the desired result of a list of numbers. The application that calls PrintingArgs exits when it reaches p.Start (), this can be avoided by using p.WaitForExit(); or just Console.Read(); . I also used both p.UseShellExecute and p.CreateNoWindow . Only if
p.UseShellExecute = false; p.CreateNoWindow = true;
makes the PrintingArgs application not show the window (even if I put only p.CreateNoWindow = true , it shows the window).
Now it comes to my mind that perhaps you are mistaken in passing arguments and forcing another program to fail and close immediately, or maybe you are not pointing to the desired file. Check the paths and names to find any error you might omit. Also using
Process.Start(fileName, args);
does not use the information configured with StartInfo in the Process instance.
Hope this helps, is considering
Sergio rosas
source share