1

I'm installing SQL Server like the code below

Process.Start("Setup.exe /q /ACTION=Install /FEATURES=SQL /INSTANCENAME=MSSQLSERVER /SQLSVCACCOUNT="<DomainName\UserName>" /SQLSVCPASSWORD="<StrongPassword>" /SQLSYSADMINACCOUNTS="<DomainName\UserName>" /AGTSVCACCOUNT="NT AUTHORITY\Network Service" /IACCEPTSQLSERVERLICENSETERMS");

When it fails to pass the pre-requisite check, the installer just disappears right away without showing the error message to the user.

I can check the reason why it failed by looking at program files folder for SQL Server but the person who is installing the software will not know where to look.

So I would like to let the user know what the error was. How can I achieve this?

Another problem I'm facing is that because this is running as a process, the program does not wait till the SQL Server installation to finish. Is there a way to run a process and wait for it to finish?

6
  • read from the stderr & stdout streams: see here how to do that Commented Apr 26, 2015 at 22:54
  • 1
    The code you posted is not valid code. the " don't match up. It is hard to tell if you are doing anything wrong if you don't show us the actual code causing the problem. Commented Apr 26, 2015 at 23:01
  • I have edited your title. Please see, "Should questions include “tags” in their titles?", where the consensus is "no, they should not". Commented Apr 26, 2015 at 23:03
  • 1
    I imagine that sending parameter /q might have something to do with it. You ask for a quiet setup, so that's what you get... Commented Apr 26, 2015 at 23:24
  • The code posted is for a demonstration purpose that I found from another post. So I didn't check to see if it runs but I was trying to illustrate the problem as I am actually doing the same way as the code I posted Commented Apr 27, 2015 at 0:07

2 Answers 2

1

So I would like to let the user know what the error was. How can I achieve this?

By reading from the stderr and stdout streams, assuming they will be used by Setup.exe to output an error message.

Another problem I'm facing is that because this is running as a process, the program does not wait till the SQL Server installation to finish. Is there a way to run a process and wait for it to finish?

You can wait for the process to exit, like this:

var process = Process.Start( .... );

// wait.
process.WaitForExit();

More information on both of these topics can be found here: How to spawn a process and capture its STDOUT in .NET? and here Process.start: how to get the output?

Sign up to request clarification or add additional context in comments.

2 Comments

link was also helpful
@fwan good to know that setup does write to stderr; it was not obvious that it would. I will add that link to the answer.
1

The /q flag is for a silent install, so it does not display any information back to the user. Try without a /q flag.

2 Comments

/q flag is used for a silent install and if an error occurs, it displays the error message. It just disappears right away. So I think /q flag or any flag is not a problem
Ok, but does the error message stick around without the q flag?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.