To continue on with the theme of unattended installation-related posts lately, what if you want to install SQL Server 2005 Express Edition in unattended mode? SQL Server 2000 had the ability to save the installation into a file called setup.iss - how nice of Microsoft to remove this feature from SQL Server 2005 … however, let’s get rolling.

Creating an unattended installation of SQL Server 2005 Express can seem like a pretty involved task at first. It can be involved too, if you want. For this example I’m going to perform a basic installation with minimal customisation so you can see the process at work.

Where to start? As with most unattended installations these days you need to create an answer file that is passed as a parameter to setup.exe … hmm, what setup.exe? When you download SQL Server 2005 Express it’s a file called SQLEXPR.EXE - no setup.exe in sight. There is a way to get it though. Let’s sidetrack for a minute and see how.

1. Run SQLEXPR.EXE
2. When the first screen appears DON’T DO ANYTHING!
3. Look in the root of C: drive (C:\) for a recently created folder that you didn’t make. Unless you have a virus doing weird stuff this will probably be the temporary folder the SQL Express installation has been extracted into. It will be a randomly-named folder, e.g. the one I just did was called "2d4f168225a7918ed69f49629587"
4. Copy the contents of this folder to another folder on your system. Note that there will be a file called "$shtdwn$.req" in there that you can’t copy - that’s fine, you don’t need it.
5. Once you’ve got a copy of all the files in the temporary folder (excluding $shtdwn$.req!) you can safely quit the installation program. No changes have been made at this point.

Now that you’ve got a nicely extracted copy of the installation files you can carry on. The above steps were necessary for what’s coming up.

Look in the folder you copied the installation files to and locate a file called "template.ini". Copy it somewhere and open it in your favourite text editor. Personally I use Microsoft Visual Studio Express Edition - it’s free and works perfectly well as a text editor as well a cut-down version of Microsoft’s flagship development environment, Visual Studio. Nice for cranking out a bit of code too … if you don’t plan to sell it.

The template.ini is actually VERY well commented - nice one Microsoft. This file is in the same format as the template.ini that comes with the full versions of SQL Server and contains a whole load of options that you don’t want to and simply can’t use with SQL Server Express. If you want to, have a read through the file and see what’s possible - here’s where you can make the installation pretty involved if you want to.

For our purposes though the installation is going to be pretty basic. The contents of the complete file are available for download at the bottom of this article (do that later). Make all the changes you think are necessary and save the file as C:\Scripts\sql-2005-express.ini.

Once you have your answer file all nicely setup and ready to use you’ll need to know how to use it. A bit of a warning here first. Without specifying all the upgrade options in the answer file I had problems running the unattended installation on a system that already had the SQL Server Native Client - it kept spewing errors about retrying the installation using a valid copy of sqlncli.msi. Either specify the upgrade options or run the installation on a system that’s never had SQL Server installed or has already had EVERYTHING SQL-related removed.

From a command prompt (or Start > Run if you’re into that) run the following command. Remember to change the file and path names to the ones that match your system.

start /wait setup.exe /qb /settings C:\Scripts\sql-2005-express.ini

If you’ve done everything right this will start the installation process and you’ll end up with a SQL Server 2005 default instance called MSSQLSERVER running on your system. Easy!

Click here to download Complete sql-2005-express.ini file used in this article

Tags: , ,