Redirect output from silent installation of SQL Server to standard error in C #?

I have the following code:

Process p = new Process();
p.StartInfo.FileName = "SQLEXPRADV_x86_ENU.exe";
p.StartInfo.Arguments = "/CONFIGURATIONFILE=Config.ini";
p.StartInfo.UseShellExecute = false;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardError = true;

p.Start();

string line;
while ((line = p.StandardOutput.ReadLine()) != null)
{
   tOutputStandard.Text += line + "\r\n";
}

while ((line = p.StandardError.ReadLine()) != null)
{
   tOutputError.Text += line + "\r\n";
}

p.WaitForExit();

The configuration file is configured to run silently. tOutputStandard and tOutputError are a TextBox that will show the result.

However, it does not display any result of installing SQL Server. I tried to run other applications and they send the output correctly, so I do not think the code is faulty.

How can I get SQL Server to output it in C #? I need to know what the error is if the installation failed.

+4
source share
3 answers

Maybe this helps. Remove the following code snippet:

string line;
while ((line = p.StandardOutput.ReadLine()) != null)
{
   tOutputStandard.Text += line + "\r\n";
}

while ((line = p.StandardError.ReadLine()) != null)
{
   tOutputError.Text += line + "\r\n";
}

Connect to the OutputDataReceived and ErrorDataReceived event handlers:

p.OutputDataReceived += this.OutputDataReceived;
p.ErrorDataReceived += this.ErrorDataReceived;

.

private void ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
    tOutputError.Text += e.Data + "\r\n";
}

private void OutputDataReceived(object sender, DataReceivedEventArgs e)
{
    tOutputStandard.Text += e.Data + "\r\n";
}
+2

, , , SQL , MSI.

MSI, temp, setup exe . exe .

, Markus Safar , .

+1

, .

Powershell. Bootstrap Setup Details.txt , ""

    C:\Program Files\Microsoft SQL Server\110\Setup Bootstrap\Log\<datestamp>\Details.txt 

, , .

0

All Articles