There is a code:
string command1 = comanda"; //Команда 1 // создаем процесс 1 System.Diagnostics.ProcessStartInfo procStartInfo1 = new System.Diagnostics.ProcessStartInfo("cmd" , st + command1); System.Diagnostics.Process pr1 = new System.Diagnostics.Process(); procStartInfo1.WindowStyle = ProcessWindowStyle.Hidden; pr1.StartInfo = procStartInfo; pr1.Start(); procStartInfo1.RedirectStandardOutput = true; procStartInfo1.UseShellExecute = false; procStartInfo1.CreateNoWindow = true; pr1.WaitForExit(); if (условие) { string command2 = comanda"; //Команда 2 // создаем процесс 2 System.Diagnostics.ProcessStartInfo procStartInfo2 = new System.Diagnostics.ProcessStartInfo("cmd" , st + command2); System.Diagnostics.Process pr2 = new System.Diagnostics.Process(); procStartInfo2.WindowStyle = ProcessWindowStyle.Hidden; pr2.StartInfo2 = procStartInfo2; pr2.Start(); procStartInfo2.RedirectStandardOutput = true; procStartInfo2.UseShellExecute = false; procStartInfo2.CreateNoWindow = true; pr2.WaitForExit(); } else { pr2.WaitForExit(); }
this is how it works, but a new process is created for the second command, and it is necessary that the second command be executed on the very first process / cmd, how it is done, please tell me, try differently, but without a new process, it’s not like ...