Hello i have a c# programm that opens a cmd.exe redirect its standardinput and runs a command, after that i take a screenshot of the console and close the window. This works fine on windows 7 but on windows 10 i get lots of "The handle is invalid" messages in the console instead of my command. This occurs only when i do that in a windowsforms application a console application works fine even on windows 10
Here is a sample code that reproduces the problem
Process myProcess = new Process();
myProcess.StartInfo.FileName = "cmd.exe";
myProcess.StartInfo.Arguments = "/K";// chcp 65001";
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardInput = true;
myProcess.StartInfo.WorkingDirectory = @"c:\";
myProcess.Start();
StreamWriter myStreamWriter = myProcess.StandardInput;
StreamWriter encodedWriter = new StreamWriter(myProcess.StandardInput.BaseStream, Encoding.GetEncoding(850));
encodedWriter.WriteLine("abcdef gä öü");
encodedWriter.Flush();
Thread.Sleep(2500);
myProcess.Kill();
it is in some way connected between redirecting the input, windows forms and windows 10. If one of these conditions is false their are no invalid handle messages