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.

Related Posts

9 thoughts on “SQL 2008 R2: Unattended Install Script (Part 2)”

  1. 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

  2. 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, I get the following error in the log file; **Value cannot be null. Parameter name: path2*** See below;

    Overall summary:
    Final result: SQL Server installation failed. To continue, investigate the reason for the failure, correct the problem, uninstall SQL Server, and then rerun SQL Server Setup.
    Exit code (Decimal): 1269611253
    Exit facility code: 940
    Exit error code: 47861
    Exit message: Value cannot be null. Parameter name: path2
    Start time: 2011-02-04 16:02:58
    End time: 2011-02-04 16:04:02
    Requested action: Install
    Log with failure: C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20110204_160147\Detail.txt

    ************************************************

    Here’s my TestSilentInstall.bat script
    start /wait setup.exe /qs /ACTION=INSTALL /FEATURES=SQL

    /IACCEPTSQLSERVERLICENSETERMS=TRUE /QUIETSIMPLE=TRUE

    /SQMREPORTING=False
    /SECURITYMODE=”SQL”

    /SQLSYSADMINACCOUNTS=”BUILTIN\ADMINISTRATORS”

    /SAPWD=”password123″ /INSTANCENAME=Test2Silent

    /SQLSVCSTARTUPTYPE=Automatic /SQLSVCACCOUNT=”NT

    AUTHORITY\SYSTEM” /SQLSVCPASSWORD=”password123″

    /FILESTREAMLEVEL=1 /TCPENABLED=”0″ /NPENABLED=”0″

    /ENABLERANU = “FALSE”

    Any advice or suggestions would be great? As i am literally banging my head against the desk at the mo, thanks a mil

  3. 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, I get the following error in the log file; **Value cannot be null. Parameter name: path2*** See below;

    Overall summary:
    Final result: SQL Server installation failed. To continue, investigate the reason for the failure, correct the problem, uninstall SQL Server, and then rerun SQL Server Setup.
    Exit code (Decimal): 1269611253
    Exit facility code: 940
    Exit error code: 47861
    Exit message: Value cannot be null. Parameter name: path2
    Start time: 2011-02-04 16:02:58
    End time: 2011-02-04 16:04:02
    Requested action: Install
    Log with failure: C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Log\20110204_160147\Detail.txt

    ************************************************

    Here’s my TestSilentInstall.bat script
    start /wait setup.exe /qs /ACTION=INSTALL /FEATURES=SQL

    /IACCEPTSQLSERVERLICENSETERMS=TRUE /QUIETSIMPLE=TRUE

    /SQMREPORTING=False
    /SECURITYMODE=”SQL”

    /SQLSYSADMINACCOUNTS=”BUILTIN\ADMINISTRATORS”

    /SAPWD=”password123″ /INSTANCENAME=Test2Silent

    /SQLSVCSTARTUPTYPE=Automatic /SQLSVCACCOUNT=”NT

    AUTHORITY\SYSTEM” /SQLSVCPASSWORD=”password123″

    /FILESTREAMLEVEL=1 /TCPENABLED=”0″ /NPENABLED=”0″

    /ENABLERANU = “FALSE”

    Any advice or suggestions would be great? As i am literally banging my head against the desk at the mo, thanks a mil

  4. 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.

  5. 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 have any major complications on the smooth running of the SQL data engine?

  6. 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 (

    )

  7. Saurabh Bhardwaj

    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 credentials as a ADMIN, when i have specifically used
    ; Windows account(s) to provision as SQL Server system administrators.

    SQLSYSADMINACCOUNTS=”BUILTIN\Administrators”
    in the command line,
    However this entry is not read in my install, Request you to guide me in this problem as it is making my Installer useless.

  8. 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

  9. 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]

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

    ACTION=”Install”

    ; 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,AutoAdvance for a simplied UI, and EnableUIOnServerCore for bypassing Server Core setup GUI block.

    ;UIMODE=”Normal”

    ; Setup will not display any user interface.

    QUIET=”True”

    ; Setup will display progress only, without any user interaction.

    QUIETSIMPLE=”False”

    ; Specify whether SQL Server Setup should discover and include product updates. The valid values are True and False or 1 and 0. By default SQL Server Setup will include updates that are found.

    UpdateEnabled=”True”

    ; Specifies features to install, uninstall, or upgrade. The list of top-level features include SQL, AS, RS, IS, MDS, and Tools. The SQL feature will install the Database Engine, Replication, Full-Text, and Data Quality Services (DQS) server. The Tools feature will install Management Tools, Books online components, SQL Server Data Tools, and other shared components.

    FEATURES=SQLENGINE,FULLTEXT

    ; Specify the location where SQL Server Setup will obtain product updates. The valid values are “MU” to search Microsoft Update, a valid folder path, a relative path such as .\MyUpdates or a UNC share. By default SQL Server Setup will search Microsoft Update or a Windows Update service through the Window Server Update Services.

    UpdateSource=”MU”

    ; Displays the command line parameters usage

    HELP=”False”

    ; Specifies that the detailed Setup log should be piped to the console.

    INDICATEPROGRESS=”False”

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

    X86=”False”

    ; Specify the root installation directory for shared components. This directory remains unchanged after shared components are already installed.

    INSTALLSHAREDDIR=”C:\Program Files\Microsoft SQL Server”

    ; Specify the root installation directory for the WOW64 shared components. This directory remains unchanged after WOW64 shared components are already installed.

    INSTALLSHAREDWOWDIR=”C:\Program Files (x86)\Microsoft SQL Server”

    ; 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”

    ; Specify the Instance ID for the SQL Server features you have specified. SQL Server directory structure, registry structure, and service names will incorporate the instance ID of the SQL Server instance.

    INSTANCEID=”MSSQLSERVER”

    ; 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 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 installation directory.

    INSTANCEDIR=”C:\Program Files\Microsoft SQL Server”

    ; Agent account name

    AGTSVCACCOUNT=”NT Service\SQLSERVERAGENT”

    ; Auto-start service after installation.

    AGTSVCSTARTUPTYPE=”Manual”

    ; CM brick TCP communication port

    COMMFABRICPORT=”0″

    ; How matrix will use private networks

    COMMFABRICNETWORKLEVEL=”0″

    ; How inter brick communication will be protected

    COMMFABRICENCRYPTION=”0″

    ; TCP port used by the CM brick

    MATRIXCMBRICKCOMMPORT=”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=”Latin1_General_CI_AS”

    ; Account for SQL Server service: Domain\User or system account.

    SQLSVCACCOUNT=”NT Service\MSSQLSERVER”

    ; Windows account(s) to provision as SQL Server system administrators.

    ; The default is Windows Authentication. Use “SQL” for Mixed Mode Authentication.

    SECURITYMODE=”SQL”

    ; Provision current user as a Database Engine system administrator for SQL Server 2012 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=”Disabled”

    ; Add description of input argument FTSVCACCOUNT

    FTSVCACCOUNT=”NT Service\MSSQLFDLauncher”

    IACCEPTSQLSERVERLICENSETERMS=”True”

    ————————————————————————————-

    Any answer to support my query will be appreciable.

    Regards,
    -Shirish

Leave a Reply to Derek Seaman, CISSP, MCSE, VCP4 Cancel Reply

Your email address will not be published. Required fields are marked *