简体   繁体   English

从应用程序安装文件静默安装SQL Server

[英]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. 作为安装我的应用程序(WPF应用程序)的一部分,需要安装SQL Server以及先决条件。 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. 因此,当用户选择安装SQL Server的选项时,在应用程序安装过程中,需要使用安装程序随附的configuration.ini文件进行静默安装。

So what i did was prepare a batch file called "InstallSQL.bat" through code which has the command to execute SQL server. 因此,我要做的是通过具有执行SQL Server命令的代码准备一个名为“ InstallSQL.bat”的批处理文件。

Now when the user choose to install SQL server, from installation code, the batch file is to be executed. 现在,当用户选择从安装代码中安装SQL Server时,将执行批处理文件。 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. 执行安装程序时,在SQL Server安装时,将提取SQL Server安装程序文件,并打开一个控制台窗口,指示安装正在进行中。 The issue is, after some time in this console window a message appears saying "Process is terminated due to stackoverflowexception". 问题是,在此控制台窗口中经过一段时间后,出现一条消息,指出“进程由于stackoverflowexception而终止”。 Can someone please help me with an alternative for installing SQL Server silently (without user interaction). 有人可以帮我一个无提示安装SQL Server的替代方法(无需用户交互)。

Thanks Nishitha 谢谢Nishitha

Well, Stackoverflow Exception is always a bad thing 好吧,Stackoverflow异常总是一件坏事
(I Guess the exception is caught when inside Process.WaitForExit() (我猜想在Process.WaitForExit()中捕获异常

But either way, i think you should not use process.WaitForExit() at all: 但是无论哪种方式,我认为您都不应该使用process.WaitForExit():
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 SQL Server 2008 R2 –无人值守静默安装

as an Added value of question, i recommend to create several ini Configurations like that for different situations (x32, x64, Etc...) 作为问题的附加值,我建议创建几种ini配置,例如针对不同情况的配置(x32,x64,Etc ...)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用C#Forms Application静默安装SQL Server - Install SQL Server Silently Using C# Forms Application 在应用程序安装程序中静默安装Crystal Report? - Silently install crystal report with my application setup? 带有SQL Server数据库的安装文件的应用程序 - application with setup file with out SQL Server database 如何制作包含C#应用程序和sql server的安装文件 - How To make setup file that contains C# application and sql server 从asp.net应用程序静默打印pdf文件 - Print pdf file silently from asp.net application 如何在 Installsheild 中静默安装 MySql 服务器? - How to silently install MySql server in Installsheild? 安装WPF应用程序时自动安装SQL Server Compact数据库.Exe文件 - Install SQL Server compact database .Exe file automatcally when I install WPF application 我是否需要在计算机上设置sql server才能运行vs 10中制作的c#桌面应用程序文件? - DO I need to setup sql server in a computer to run c# desktop application file made in vs 10? 在.NET Windows应用程序中创建可以使用SQL Server 2005的EXE或安装文件 - Create an EXE or setup file in .NET Windows application which can use SQL Server 2005 使用 C# 应用程序安装 SQL Server Express - Install SQL Server Express with C# application
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM