简体   繁体   中英

Install SQL Server silently from application setup file

As part of installing my application (WPF application), need to install SQL Server as well as a prerequisite. So when the user choose the option to install SQL Server, during the course of application installation, it need to get installed silently using the configuration.ini file provided with the setup.

So what i did was prepare a batch file called "InstallSQL.bat" through code which has the command to execute SQL server.

Now when the user choose to install SQL server, from installation code, the batch file is to be executed. The code is as below

        int ExitCode;
        ProcessStartInfo ProcessInfo;
        Process process;            

        ProcessInfo = new ProcessStartInfo(batchFilePath);
        ProcessInfo.CreateNoWindow = true;
        ProcessInfo.UseShellExecute = false;

        ProcessInfo.WorkingDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
        // *** Redirect the output ***
        ProcessInfo.RedirectStandardError = true;
        ProcessInfo.RedirectStandardOutput = true;
        process = Process.Start(ProcessInfo);
        process.WaitForExit();
        MessageBox.Show("ExitCode: " + process.ExitCode);

When execute the setup, at the point of SQL Server installation, the SQL Server setup files are extracted and a console window opens up indicating installation is in progress. The issue is, after some time in this console window a message appears saying "Process is terminated due to stackoverflowexception". Can someone please help me with an alternative for installing SQL Server silently (without user interaction).

Thanks Nishitha

Well, Stackoverflow Exception is always a bad thing
(I Guess the exception is caught when inside Process.WaitForExit()

But either way, i think you should not use process.WaitForExit() at all:
but catch the Event and Give user feedback.

EDIT:

For the Unattended stuff... You could quickly Google it!
SQL Server 2008 R2 – Unattended Silent Install

as an Added value of question, i recommend to create several ini Configurations like that for different situations (x32, x64, Etc...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM