Pages

Saturday, August 3, 2013

Integrating the silent or unattended installation of SQL Server 2008 R2 in the C# code base


The code to integrate the silent installation in to the C# code base is very simple. We will start the process of setup and attach the arguments which are required. The code to do so is as follows:-

 
//Creating a process to do the silent installation
Process p = new Process();
 
//File names and File Path along with the process arguments
p.StartInfo.FileName = @"C:\DemoSetup\SQLEXPRWT_x86_ENU.exe";
p.StartInfo.Arguments = @"/q /ConfigurationFile=C:\DemoSetup\SQLDemoConfig.ini";
 
p.StartInfo.UseShellExecute = false;
p.Start();
 
//Waiting for the process to complete
p.WaitForExit();
 

 

Note:- To know the contents of the SQLDemoConfig.ini file please refer my earlier blogs.

This step p.WaitForExit(); is very important because we need to wait till the sql server installation is complete before setting the TCP port otherwise as there is no sql server and the service is not available an exception is thrown.

No comments:

Post a Comment