It is necessary to implement printing of console output in textbox form. Did this:
Process cmd = new Process(); cmd.StartInfo = new ProcessStartInfo(@"cmd"); cmd.StartInfo.RedirectStandardOutput = true; cmd.StartInfo.RedirectStandardInput = true; cmd.StartInfo.UseShellExecute = false; cmd.StartInfo.CreateNoWindow = true; cmd.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; cmd.OutputDataReceived += new DataReceivedEventHandler(SortOutputHandler); cmd.Start(); cmd.StandardInput.WriteLine(ip_string); cmd.BeginOutputReadLine(); ........ void SortOutputHandler(object sender, DataReceivedEventArgs e) { Trace.WriteLine(e.Data); this.BeginInvoke(new MethodInvoker(() => { textBox4.AppendText(e.Data ?? string.Empty); })); } I run the command curl --socks5 127.0.0.1:9050 http://checkip.amazonaws.com
With this approach, the entire text from cmd is included in the textbox, which includes not only the ip address I need, but also the command itself and other trash that I don’t need. Tell me how to get as a result of the result of the command, and not all at once?