Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- string PS_path = name;
- System.Diagnostics.Process ps = new System.Diagnostics.Process();
- ps.StartInfo.CreateNoWindow = false;
- ps.StartInfo.FileName = PS_path;
- string argStr = "";
- for (int i = 1; i < args.Length; i++)
- {
- argStr += args[i] + " ";
- }
- ps.StartInfo.Arguments = argStr;
- ps.StartInfo.RedirectStandardError = true;
- ps.StartInfo.RedirectStandardInput = true;
- ps.StartInfo.RedirectStandardOutput = true;
- ps.StartInfo.UseShellExecute = false;
- ps.Start();
- string oldOutput="";
- string oldError="";
- StreamReader input = new StreamReader(Console.OpenStandardInput());
- while (!ps.HasExited)
- {
- string line;
- line = ps.StandardOutput.ReadLine();
- if (line != null)
- Console.WriteLine(line);
- line = ps.StandardError.ReadLine();
- if (line != null)
- Console.Error.WriteLine(line);
- }
- if (ps.ExitCode != 0)
- {
- Console.ReadKey();
- }
- System.Environment.Exit(ps.ExitCode);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement