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.

Abdulsalam Elsharif
  • 4,773
  • 7
  • 32
  • 66

1 Answers1

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;
    .... 
Steve
  • 213,761
  • 22
  • 232
  • 286
  • 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. – Steve Apr 03 '15 at 19:05
  • Thank you Steve for your time, Can you check the question update please. – Abdulsalam Elsharif Apr 03 '15 at 19:12