Quantcast
Viewing all articles
Browse latest Browse all 5760

How to install SQL Server Express without account service password

Hello people,

I'm attempting to install SQL Server 2012 Express from command line with silent mode, this installation is embedded with a console application:

static void Main(string[] args)
{
    Console.WriteLine("Old instances count: " + Tools.GetLocalSqlServerInstanceNames().Count);
    string SetupDirectory = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);
    string sqlSetupFileName ="SQLEXPR_x86_ENU.exe";

    if (System.IO.File.Exists(SetupDirectory + @"\" + sqlSetupFileName))
    {
        string command = "SQLEXPR_x86_ENU";
        string argument = string.Format("/X: \"{0}\\SQLEXPRESSSTUP\", SetupDirectory);
        int resu = Tools.ExecuteCommand(command, argument);

        if (resu == 0)
        {
            argument = "";
            argument += " " + "/ACTION=Install";
            argument += " " + "/FEATURES=SQLEngine";
            argument += " " + "/INSTANCENAME=SQLEXPRESS";
            argument += " " + "/Q";
            argument += " " + "/HIDECONSOLE";
            argument += " " + "/SECURITYMODE=SQL";
            argument += " " + "/SAPWD=dotsquare";
            //argument += " " + "/SQLSVCACCOUNT=" + System.Security.Principal.WindowsIdentity.GetCurrent().Name;Environment.UserDomainName
            argument += " " + "/SQLSVCACCOUNT=" + Environment.UserDomainName + @"\" + "LocalSystem";
            //argument += " " + "/SQLSVCPASSWORD=\"StrongPassword\"";
            argument += " " + "/AddCurrentUserAsSQLAdmin";
            argument += " " + "/IACCEPTSQLSERVERLICENSETERMS=True";

            try
            {
                System.Diagnostics.Process processObj = System.Diagnostics.Process.Start(SetupDirectory + @"\SQLEXPRESSSTUP\Setup.exe", argument);
                do
                {
                    //refresh the process
                    processObj.Refresh();
                } while (!processObj.WaitForExit(1000));

                Console.WriteLine("Process exited with {0}!", processObj.ExitCode);
            }
            catch
            {
                Console.WriteLine("An error has occured!");
            }
        }
        else
        {
            Console.WriteLine("Extraction failed, please try again !");
        }
    }
    else
    {
        Console.WriteLine("SQL Setup is not found !");
    }

    Console.ReadKey();
}

This program extracts and fires up the SQL Server Express setup but it fails when it reaches the service accounts step. I want to use any other account to pass the step and complete the setup.

Please help.


Viewing all articles
Browse latest Browse all 5760

Trending Articles