SQL 2008 R2: Unattended Install Script (Part 2)

Note: For my updated version for SQL Server 2012, see my new article here.

Many of you probably do frequent SQL 2008 R2 installation. Be it in a development environment, or deployment in production environments. For years Microsoft has given people the ability to perform unattended installations of SQL. Starting with SQL 2008 R2, it is now sysprep friendly and can be included in your golden images. But that topic is for another time! Today I wanted to provide you two scripts that automate the SQL 2008 R2 installation process the old fashion way.

You can deploy SQL 2008 R2 in 5-7 minutes, depending on your hardware using this method. You will of course need to modify some variables in the script to fit your environment. The scripts assume you are deploying on Windows Server 2008 R2. They should work with minor to no modifications on legacy operating systems.

First, you need to create an INI file that contains the settings you want. In my case I called it SQL-2008R2-base.ini. That file contains the following:

—–
;SQL SERVER 2008 R2 Configuration File
;Version 1.0, 5 May 2010
;

[SQLSERVER2008]
; Specify the Instance ID for the SQL Server features you have specified. SQL Server directory structure, registry structure, and service names will reflect the instance ID of the SQL Server instance.
INSTANCEID=”MSSQLSERVER

; Specifies a Setup work flow, like INSTALL, UNINSTALL, or UPGRADE. This is a required parameter.
ACTION=”Install”

; Specifies features to install, uninstall, or upgrade. The list of top-level features include SQL, AS, RS, IS, and Tools. The SQL feature will install the database engine, replication, and full-text. The Tools feature will install Management Tools, Books online, Business Intelligence Development Studio, and other shared components.
FEATURES=SQLENGINE,CONN,SSMS,ADV_SSMS

; Displays the command line parameters usage
HELP=”False”

; Specifies that the detailed Setup log should be piped to the console.
INDICATEPROGRESS=”False”

; Setup will not display any user interface.
QUIET=”False”

; Setup will display progress only without any user interaction.
QUIETSIMPLE=”True”

; Specifies that Setup should install into WOW64. This command line argument is not supported on an IA64 or a 32-bit system.
X86=”False”

; Specifies the path to the installation media folder where setup.exe is located.
MEDIASOURCE=”z:”

; Detailed help for command line argument ENU has not been defined yet.
ENU=”True”

; Parameter that controls the user interface behavior. Valid values are Normal for the full UI, and AutoAdvance for a simplied UI.

; UIMODE=”Normal”

; Specify if errors can be reported to Microsoft to improve future SQL Server releases. Specify 1 or True to enable and 0 or False to disable this feature.
ERRORREPORTING=”False”

; Specify the root installation directory for native shared components.
INSTALLSHAREDDIR=”D:Program FilesMicrosoft SQL Server”

; Specify the root installation directory for the WOW64 shared components.
INSTALLSHAREDWOWDIR=”D:Program Files (x86)Microsoft SQL Server”

; Specify the installation directory.
INSTANCEDIR=”D:Program FilesMicrosoft SQL Server”

; Specify that SQL Server feature usage data can be collected and sent to Microsoft. Specify 1 or True to enable and 0 or False to disable this feature.
SQMREPORTING=”False”

; Specify a default or named instance. MSSQLSERVER is the default instance for non-Express editions and SQLExpress for Express editions. This parameter is required when installing the SQL Server Database Engine (SQL), Analysis Services (AS), or Reporting Services (RS).
INSTANCENAME=”MSSQLSERVER

; Agent account name
AGTSVCACCOUNT=”NT AUTHORITYNETWORK SERVICE”

; Auto-start service after installation.
AGTSVCSTARTUPTYPE=”Automatic”

; Startup type for Integration Services.
ISSVCSTARTUPTYPE=”Automatic”

; Account for Integration Services: DomainUser or system account.
ISSVCACCOUNT=”NT AUTHORITYNetworkService

; Controls the service startup type setting after the service has been created.
ASSVCSTARTUPTYPE=”Automatic”

; The collation to be used by Analysis Services.
ASCOLLATION=”Latin1_General_CI_AS”

; The location for the Analysis Services data files.
ASDATADIR=”Data”

; The location for the Analysis Services log files.
ASLOGDIR=”Log”

; The location for the Analysis Services backup files.
ASBACKUPDIR=”Backup”

; The location for the Analysis Services temporary files.
ASTEMPDIR=”Temp”

; The location for the Analysis Services configuration files.
ASCONFIGDIR=”Config

; Specifies whether or not the MSOLAP provider is allowed to run in process.
ASPROVIDERMSOLAP=”1″

; A port number used to connect to the SharePoint Central Administration web application.
FARMADMINPORT=”0″

; Startup type for the SQL Server service.
SQLSVCSTARTUPTYPE=”Automatic”

; Level to enable FILESTREAM feature at (0, 1, 2 or 3).
FILESTREAMLEVEL=”0″

; Set to “1” to enable RANU for SQL Server Express.
ENABLERANU=”False”

; Specifies a Windows collation or an SQL collation to use for the Database Engine.
SQLCOLLATION=”SQL_Latin1_General_CP1_CI_AS”

; Account for SQL Server service: DomainUser or system account.
SQLSVCACCOUNT=”NT AUTHORITYNETWORK SERVICE”

; Default directory for the Database Engine user databases.
SQLUSERDBDIR=”K:Microsoft SQL ServerMSSQLData”

; Default directory for the Database Engine user database logs.
SQLUSERDBLOGDIR=”L:Microsoft SQL ServerMSSQLDataLogs”

; Directory for Database Engine TempDB files.
SQLTEMPDBDIR=”T:Microsoft SQL ServerMSSQLData”

; Directory for the Database Engine TempDB log files.
SQLTEMPDBLOGDIR=”T:Microsoft SQL ServerMSSQLDataLogs”

; Provision current user as a Database Engine system administrator for SQL Server 2008 R2 Express.
ADDCURRENTUSERASSQLADMIN=”False”

; Specify 0 to disable or 1 to enable the TCP/IP protocol.
TCPENABLED=”1″

; Specify 0 to disable or 1 to enable the Named Pipes protocol.
NPENABLED=”0″

; Startup type for Browser Service.
BROWSERSVCSTARTUPTYPE=”Automatic”

; Specifies how the startup mode of the report server NT service. When
; Manual – Service startup is manual mode (default).
; Automatic – Service startup is automatic mode.
; Disabled – Service is disabled
RSSVCSTARTUPTYPE=”Automatic”

; Specifies which mode report server is installed in.
; Default value: “FilesOnly
RSINSTALLMODE=”FilesOnlyMode

; Accept SQL Server 2008 R2 license terms
IACCEPTSQLSERVERLICENSETERMS=”TRUE”

——

Next, you need to use a little script which calls the SQL installer and points it to the INI file that you’ve created. This script needs one parameter, the name of the SQL administrator’s group. Generally this group would live in AD. You should use the format domainaccount as the parameter. The script also configures Windows Server 2008 R2 auditing so that SQL can inject entries into the Windows security event log. The SQL 2008 R2 installation files must be present on the Z: drive, or you will need to change the script. I save this file as SQL-2008R2-Base.cmd.

——
:: SQL 2008 R2 Installation Script:: v1.1 03 July 2010
@echo off
z:
IF “%1″==”” GOTO Error

:: Install base SQL Server 2008 Enterprise

echo Installing base SQL Server 2008 R2…

“z:setup.exe” /CONFIGURATIONFILE=D:sql-2008R2-Base.ini /INDICATEPROGRESS /SQLSYSADMINACCOUNTS=”%1″

:: Configure Windows Server 2008/R2 auditing policy

auditpol /set /subcategory:”application generated” /success:enable /failure:enable

:: Remove left-over SQL 2008 entry from the start menu

rmdir “C:ProgramDataMicrosoftWindowsStart MenuProgramsMicrosoft SQL Server 2008″ /q /s

exit /B

:ErrorEcho Script requires DBAdmin argument in the form domainGroup

——-

To peform the unattended installation I perform the following steps:

1. Mount SQL 2008 R2 installation files to the Z drive.
2. Copy the two scripts to the root of the D: drive.
3. Open a command window and CD to the Z: drive.
4. Type “D:SQL-2008R2-base.cmd contosoSQL01-DBAdmin” (use your group name)

Come back in 5-10 minutes and you should get a setup result of “0”. Happy SQL installs! If you want to get really crazy with the switches, check out this MSDN Aritcle for all the options.

Print Friendly, PDF & Email

Related Posts

Subscribe
Notify of
9 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
August 3, 2010 4:39 am

When I tried this, it asks for the Product Key # to be entered. Is there anyway to supply this license #, or have you encountered this? Thanks! benlindelof (at) yahoo.com

February 4, 2011 8:26 am

ahoy derek858 how things? I’m busy trying to perform a silent install of SQL Express 2008 and you’ll be glad to know I’ve been referred to least 3 times on other forums to your blog, so if figured your the go to guy;) As it stands I have a custom wrapper which after installing the application then creates a BAT script along with user inputted data such as SQL Username & Password to perform a silent install of SQL Express 2008 so it can create an application specific instance of the SQL Server. However when I run my TestSilentInstall.bat script,… Read more »

February 4, 2011 8:31 am

ahoy derek858 how things? I’m busy trying to perform a silent install of SQL Express 2008 and you’ll be glad to know I’ve been referred to least 3 times on other forums to your blog, so if figured your the go to guy;) As it stands I have a custom wrapper which after installing the application then creates a BAT script along with user inputted data such as SQL Username & Password to perform a silent install of SQL Express 2008 so it can create an application specific instance of the SQL Server. However when I run my TestSilentInstall.bat script,… Read more »

February 4, 2011 7:43 pm

Ruairi,

You might want to have SQL generate a configurationfile.ini and then try your automated install using that.

To generate the .INI you need to do a little trickery with the SQL express installer. Use the following switches:

/ACTION=Install /UIMODE=Normal

On the Ready to Install page you will see the path to the configuration file it created.

February 9, 2011 2:44 am

Hi Derek, Thanks for your reply, tried your suggestion and it worked a treat, thanks very much. Used the configurationfile.ini that the SQL generates when doing a normal install with some minor alterations to have the customisble silent install. Both my .INI scripts and my .BAT scripts worked well. Though I was wondering in your opinion do you think it would be alright to use these scripts as part of an embedded install for this application that I am working on? For instance take the parameter x86=”True”, if an install was to be done on a 64-bit machine would this… Read more »

February 9, 2011 6:20 am

Ruairi,

You probably would need two .INI files and have the batch file use the proper one depending if the host is x86 or x64. But try your .INI and batch file on a x64 machine and see what happens. In a batch file you can detect the architecture with:

IF “%PROCESSOR_ARCHITECTURE%”==”x86” (

) ELSE (

)

Saurabh Bhardwaj
June 9, 2011 10:29 pm

Hi Derek, While searching for a problem that I am facing in unattended installation of SQL , your Blogs name is refered to at alot of places, So I think you would be the best who could guide me in my problem, Exactly I am making a installer via installshield which has a SQL 2008 R2 prerequisite, I have made the config files throgh the command prompt as told in MSDN.My installer is working fine ini both upgrade and fresh install, however when I actually start SQL and try to work on it , It is not accepting my windows… Read more »

Anonymous
June 24, 2011 1:47 am

Hi Saurabh,
Try using this line as a parameter in your config files;

ADDCURRENTUSERASSQLADMIN=True

and remove the line SQLSYSADMINACCOUNTS=”BUILTIN\Administrators”. I had a similiar problem building an installer myself and found that removing BUILTIN\Administrators rectified it.

Cheers

Shirish Nagar
July 23, 2018 2:34 pm

Hi Derek and everyone, I am having FULL ISO for SQLServer 2008R2 which works fine with UI installation. Due to automation script, I need to perform silent installations for various sqlservers (2008R2, 2012, 2014, 2016 and 2017). For the same, I am performing using 1 configurationfile.ini which works for all sqlservers (2012,2014,2016,2017) except 2008R2. When performing for 2008R2, it always initiates the UI which is not happening with other sqlservers. Can someone please share the possible reason and solution for the issue I am facing? Below is the ConfigurationFile.ini file I am using ————————————————————————————- ;SQL Server 2012 Configuration File [OPTIONS]… Read more »