I'm trying to Start command promt process with args. Now I want to obtain information about errors if they exist.
someProcess = System.Diagnostics.Process.Start(cmd, someArgs);
Best regards, loviji
See Question&Answers more detail:osI'm trying to Start command promt process with args. Now I want to obtain information about errors if they exist.
someProcess = System.Diagnostics.Process.Start(cmd, someArgs);
Best regards, loviji
See Question&Answers more detail:osThe other answers are correct. Here is some code you could use:
ProcessStartInfo startInfo = new ProcessStartInfo(cmd, args);
startInfo.UseShellExecute = false;
startInfo.RedirectStandardError = true;
Process someProcess = Process.Start(startInfo);
string errors = someProcess.StandardError.ReadToEnd();
Note that if the file is not found you won't get an error on standard error. You will get an exception instead.