I am trying to open a Notepad process and write strings into it after initialization. This is just a "POC" for my real goal which is to start a process, a user terminal of some sort, and completely control it through my app.
I searched the question here in different forms and found this link which was exactly what I was searching for!
Unfortunately, it doesn't work :/
This is the simple code:
static void Main(string[] args)
{
ProcessStartInfo ProcessInfo = new ProcessStartInfo("notepad");
ProcessInfo.RedirectStandardInput = true;
ProcessInfo.RedirectStandardOutput = true;
ProcessInfo.RedirectStandardError = true;
ProcessInfo.UseShellExecute = false;
ProcessInfo.ErrorDialog = false;
Process aProcess = new Process();
aProcess.StartInfo = ProcessInfo;
aProcess.Start();
StreamWriter processWriter = aProcess.StandardInput;
StreamReader processReader = aProcess.StandardOutput;
StreamReader processError = aProcess.StandardError;
while (!aProcess.Responding)
{
System.Threading.Thread.Sleep(5000);
}
processWriter.WriteLine("OMG IT FINALLY WORKED");
aProcess.WaitForExit();
}
The notepad process opens up but the information I tried to write with my processWriter is not present.
Does anyone have any idea why it's not working and how to make it work without walkarounds like using keystrokes and stuff?
Thanks in advance!