I know similar questions are overflowing this website (pun intended), but I cannot find get this to work without closing the .bat file I'm running. I'm sorry that I'm not very skillful at this, but any help is seriously appreciated.
What works:
// Start the child process.
Process p = new Process();
// Redirect the output stream of the child process.
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.FileName = @"C:\Temp\batch.bat";
p.Start();
string output = p.StandardOutput.ReadToEnd();
string DataDate =(output.Substring(output.LastIndexOf("echo date:") + 11));
string DataID1 =(output.Substring(output.LastIndexOf("echo id1:") + 10));
string DataID2 =(output.Substring(output.LastIndexOf("echo id2:") + 10));
string DataStatus =(output.Substring(output.LastIndexOf("echo status:") + 13));
This here opens a batch.bat file, which prints several lines that I can get to strings, such as: "echo date: 15.02.2019" goes to string DataDate. But I would like to open a command prompt and type new values myself without the command prompt closing. I'm using a button to run that code above. I think I to open the cmd process and store it every time there is a new line? How can I keep process alive and update my strings with newer values? For example I could type in the cmd prompt "echo date: 18.02.2019" and then that value would be saved.