views:

33

answers:

2

I need the program to give the output of the batch script, and at the moment it's just printing

System.IO.StreamReader

and it should be printing whatever the batch script says

This is only the part that has to do with starting a new process, the variables like the path to the file are declared and the script itself runs but doesn't show proper output

Process Uninstaller = new Process();

Uninstaller.StartInfo.FileName = Path.Combine(uninstalldirectory, BatchProcessFileName);
Uninstaller.StartInfo.UseShellExecute = false;
Uninstaller.StartInfo.CreateNoWindow = true;
Uninstaller.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
Uninstaller.StartInfo.RedirectStandardOutput = true;
Uninstaller.Start();
StreamReader ReadUninstallerOutput = Uninstaller.StandardOutput;
Uninstaller.Close();
string OutputEnd = ReadUninstallerOutput.ReadToEnd();
Console.WriteLine(ReadUninstallerOutput);

ReadUninstallerOutput.Close();
Console.WriteLine("Uninstallation Successful");
+2  A: 

That's because you're having the Console write ReadUninstallerOutput, which is an object, not the string that has the data you want, and all the method is doing is calling the ToString method on that type. Judging from your code, you would want to replace:

Console.WriteLine(ReadUninstallerOutput);

with:

Console.WriteLine(OutputEnd);
nasufara
Both of you got it right, thanks
Indebi
+1 to make the points split fair ;-)
Gonzalo
+1  A: 

Replace

Console.WriteLine(ReadUninstallerOutput);

with

Console.WriteLine(OutputEnd);
Gonzalo
Both of you got it right, thanks
Indebi