1

I work on Setup application to install all requirement for my WPF product, one of the requirement is SQL Server 2012 Express, the code below is to install it after I generate the configuration file for silent installation :

private void SetupSQLServer()
{
        string result = "";
        string commandLine = "";

        if (os64)
            commandLine = string.Format(@"{0}\SQLServer\sql64\setup.exe PCUSOURCE={0}\SQLServer\sql64 /SAPWD=""p@ssw0rd"" /CONFIGURATIONFILE={0}\SQLServer\ConfigurationFile64.ini /HIDECONSOLE", setupFolder);
        else
            commandLine = string.Format(@"{0}\SQLServer\sql86\setup.exe PCUSOURCE={0}\SQLServer\sql86 /SAPWD=""p@ssw0rd"" /CONFIGURATIONFILE={0}\SQLServer\ConfigurationFile32.ini /HIDECONSOLE", setupFolder);

        startInfo.WorkingDirectory = setupFolder;
        startInfo.Arguments = "/c " + commandLine;
        startInfo.RedirectStandardOutput = true;
        startInfo.UseShellExecute = false;

        process.StartInfo = startInfo;

        try
        {
            process.Start();
        }
        catch (Exception e)
        {
            result = e.Message;
        }

        result = result + "\n" + process.StandardOutput.ReadToEnd();

        UpdateStepResult(result);
    }

There's no error in the code but it does not work .. when I run the code the command window appear and disappear and nothing happen.

UPDATE:

When I used:

fileName = string.Format(@"{0}\SQLServer\sql64\setup.exe", setupFolder);

The installation is run but without configuration file, when I used:

fileName = string.Format(@"{0}\SQLServer\sql64\setup.exe /CONFIGURATIONFILE={0}\SQLServer\sql64\ConfigurationFile64.ini", setupFolder);

It gives me this error "The system cannot find the file specified" !!! The file is exist in the same folder !!

Please can you help me to discover the mistake.

Thanks in advance.

2
  • Do the Setup application run under Administrator privilleges? Commented Apr 3, 2015 at 15:42
  • I tried to run it with administration privileges (Right click and run as administrator) Commented Apr 3, 2015 at 16:09

1 Answer 1

2

The ProcessStartInfo requires the FileName property to be valid. Your code above doesn't set it but pass everything as Arguments.

Probably you need to separate the command line in two parts. The Executable to run and the arguments to pass

   if (os64)
   {
        fileName = string.Format("{0}\SQLServer\sql64\setup.exe", setupFolder);
        commandLine = string.Format(@"PCUSOURCE={0}\SQLServer\sql64 /SAPWD=""p@ssw0rd"" /CONFIGURATIONFILE={0}\SQLServer\ConfigurationFile64.ini /HIDECONSOLE", setupFolder);
    }
    else
    {
         // Same for 32 bit
         .....
    }
    ....
    startInfo.FileName = fileName;
    .... 
Sign up to request clarification or add additional context in comments.

2 Comments

It is not an easy task to run an automated installation of Sql Server. I can't say why you configuration file doesn't work. Perhaps it is better to post a new question with the details of your Configuration file and the error received.
Thank you Steve for your time, Can you check the question update please.

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.