0

I am trying to make a setup project which installs an SQL instance with password. My requirement is I want full installation in silent mode except Instance name. Is there any way I can supply any command in my command line that will allow the user to put his own Instance name? I tried /qn, /qb for 2005 and /qs for 2008 but they display all the dialog box.

Thanks in advance.

hiren soni
  • 174
  • 2
  • 2
  • 17
  • 1
    I think you'd have to prompt for the instance name through UI of your own, then pass the name on the command line and do a fully quiet install. – Damien_The_Unbeliever Oct 03 '12 at 13:20
  • Thanks @Damien_The_Unbeliever Thats what I decided to do. But the problem is how can I set the command line at run time? Can you give me any example? – hiren soni Oct 04 '12 at 09:36
  • What tool are you using to build your setup? The specifics may vary between different tools – Damien_The_Unbeliever Oct 04 '12 at 09:38
  • I am using standard deploy and setup project of visual studio 2008 – hiren soni Oct 04 '12 at 09:46
  • [this post](http://openlandscape.net/2009/03/23/executing-shell-commands-from-a-visual-studio-deployment-project/) shows a way to write a small `.vbs` script that assembles a command line and runs it, having been passed a parameter as a `CustomActionData`. You might be able to work from that. – Damien_The_Unbeliever Oct 04 '12 at 09:49
  • Hi @Damien_The_Unbeliever I tried to install sql server somethng like you suggested. I have written a command line on Install. I also have some code on Commit. It starts installation on Install and straight goes to the Commit method. How can I make it wait until sql installation is finished? – hiren soni Oct 04 '12 at 12:18

1 Answers1

1

The parameter to install without the SQL Server install window is /Q instead of /QS. See Microsoft's documentation here.

To supply an instance name, you need the /INSTANCENAME parameter. Here is an example of how to install SQL Server via command prompt without a SQL Server window:

SETUP.exe /Q /IACCEPTSQLSERVERLICENSETERMS /ACTION=install /FEATURES=SQL /INSTANCENAME=YourInstanceNameHere /SECURITYMODE=SQL /SAPWD="SQL Admin Password Here" /SQLSYSADMINACCOUNTS=""NT Authority\System"" /ADDCURRENTUSERASSQLADMIN=False

SETUP.exe = SQL Server install file

/Q = quiet install

/IACCEPTSQLSERVERLICENSETERMS = Required for quiet install

/ACTION = tells installer to install SQL

/FEATURES = tells installer which features to install

/INSTANCENAME = the name you want your SQL Server instance to be

/SECURITYMODE = tells SQL to use SQL Server Authentication instead of Windows Auth

/SAPWD = creates the password for the SQL Server Login

/SQLSYSADMINACCOUNTS = installs SQL with specified admin user

/ADDCURRENTUSERASSQLADMIN = self explanatory

Here is a C# example to run the process from an application, note: like Command Prompt, your application will need to run as an administrator:

        System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
        startInfo.CreateNoWindow = true;
        startInfo.UseShellExecute = false;
        startInfo.RedirectStandardError = true;
        startInfo.RedirectStandardOutput = true;
        startInfo.FileName = "path to SETUP.exe file";
        startInfo.Arguments = "the above mentioned arguments";

        System.Diagnostics.Process processObj = new System.Diagnostics.Process();
        processObj.StartInfo = startInfo;
        processObj.Start();                

        do
        {
            //refresh the process
            processObj.Refresh();

        } while (!processObj.WaitForExit(1000));

Tested on SQL Server 2019 and Visual Studio 2013.