SQL Server 2005 – Unattended Installations
In this tutorial you will learn about SQL Server 2005 – Unattended Installations, How to perform a silent installation of SQL Server, To Create .iss file, Basic Header Information for Our Script Files, Checking for the Parameters within the Script, Sample of the Combination of the .iss File within the Batch File, To set the security modes use the following code.
Unattended installation is an installation of SQL Server that is done entirely using a script embedded in an .ini file. This file can be created using any text editor. This file is composed of a single section containing multiple parameters relating to the different configuration setting. Once this file has been created, the user has to navigate to the command prompt and type the command setup.exe/settings
SQL Server supports the capability to take a configuration file containing components for the purpose of an installation of the server. This file will contain all the details of components to be installed with depth of customization of the components required. In this tutorial we shall examine how to perform a silent installation of SQL Server. We shall script an .iss file.
There are examples of an .iss file on the installation CD of SQL Server. These samples are for the default installation of the SQL Server, OLAP etc.
To Create .iss file
1. Check whether any other .iss file exists in the operating system by navigating to C:\WinNT.
2. If yes, rename the files to some other name. These files are not required once an installation of the SQL Server is complete and may have been created by previous installations.
3. Insert the installation CD into the drive and in the command prompt specify
x:\Setup\SQLSetup.exe –r.
4. The –r parameter records a unattended installation within the Winnt directory and then opens the installation wizard. The installation wizard screen is displayed.
5. Select the Advanced options to choose the options required. Click Next.
6. Select the Record Unattended .ISS File option in the installation wizard.
7. We shall ignore the Registry option which is intended to restore the registry to the pre-SQL installation state. We shall also ignore the Maintain a virtual Server for Failover clustering as this option is to be used if clusters are being installed. Click Next.
8. The standard installation screens appear. The user can navigate through these screens selecting the options required.
9. Once the installation wizard completes the task, navigate to C:\WINNT and open the new file called setup.iss with the current date and time. Look at the script in the file.
10. Enter the following command in the command line
< name of drive >:\Setup\SQLSetup.exe –z –s –f1c:\winnt\setup.iss
11. –z is to ensure that the setup will run on systems that have more than 256 MB RAM. –s forces setup to run without user input. –f1 allows users specify the path of the .iss file. If path is not specified, the setup looks for an .iss file in the default location.
12. The .iss file can now be manually edited to cater to the needs of the administrator.
The above script procedure does not install the SQL Server. It assists the administrator in creating the script automatically.
Now that the script is created, the variables within the script will have to be initialized. The .iss file that is then generated will install the SQL Server.
The script file created above is a DOS or batch file script. Though it can be ported to Windows Scripting Host (WSH), it is very simple to administer in the current format.
Separate script files can be created for each installation or different values can be passed for the installations.
The first step is to define the header information. This is illustrated below.
Basic Header Information for Our Script Files.
Header information makes the file more maintainable. All information regarding referenced parameters, meanings in the context of the script, sample value of the parameter, notes etc are included in the header file. This section can be modified as and when required.
The next part of the script is parameter checking. The ‘If” clause is used to check the existence of the parameter. If it does not exist, then a message is sent to the console window alerting the user that the parameter contains no value and a log is registered and the batch file is exited.
It must be noted that some of the variables have been supplied with default values and if the user forgets to supply the value the same will be set to default. The code has to now check for the value of the SycActName variable. If the value is the LocalSystem then SQL Server will be installed as LocalSystem and hence there is no need to check for SycActDom and SycActPwd variables. If the SycActName is not LocalSystem then we need to check for the other two variables and the user must provide the values. The purpose of using this conditional logic is to enable the installation in a number of slightly varying situations with ease. The next step is to modify and generate the .iss file. Open the .iss file and paste the echo command at the beginning of every line and >>%ISS% at the end of every line other than the first line. Add a > %ISS% sign at the end of the first line. The file will begin to look like the sample below.
Having completed the above process, we now need to place the variables in the place of the values in the .iss file. For instance (echo szDir=%PROGRAMFILES%\Microsoft SQL Server\MSSQL) >> %ISSFile% Will become (echo szDir=%SQLpath%) >> %ISSFile% After completing the editing, copy the entire file and place the text into the batch file under the parameter checking section as under:
Finally, to extend the logic for a Service Account we need to replace in the code the following section.
With this we have come to the end of the process of creating our .iss file. Copy this file into the Windows Directory and rename it as setup.iss. Now create the command line within the batch file as under:
You can use the Start/wait command to tell the batch file to wait till the installation of the SQL Server has finished. Once it has finished we can check for successful installation by setting the value for RETVAL. In this section of the tutorial we have learnt how to create an .iss file and use for a unattended installation of the SQL Server. In the section that follows we shall see how to do a custom installation of the server. Checking for the Parameters within the Script.
Sample of the Combination of the .iss File within the Batch File.
To set the security modes use the following code.