I have an issue that I can not figure out. I have a Windows form with a Text Box, Button, and List Box. I want to type an IP into the text box, push the button, and redirect the schtasks output to my list box. However, I never get anything more than the first line. Also, my code works fine when redirecting to a text file. Below is my code.
string machineName = textBox1.Text;
Process process = new Process();
process.StartInfo.FileName = "schtasks";
process.StartInfo.Arguments = " /query /s " + machineName;
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardOutput = true;
process.StartInfo.CreateNoWindow = true;
process.Start();
string output = process.StandardOutput.ReadToEnd();
process.WaitForExit();
lstOutput.Items.Add(output);
My code to write to text file was the same except at the end, instead of writing to the listbox, I created a text writer and gave it a location for the file. Can anyone figure out what I have done wrong?