anyone have script or procedures to install SQL Server 2008 Express, set up the database for the app and finally install a client .NET WinForm application?
2 Answers
In situations like this where I'm relying on third-party products (SQL Server Express), I tend to use command-line driven installs (either directly in a cmd file or called from a 'proper' install tool). This site shows you how to install Express from the command line, then you can use the SQL Express utility for object creation. This method is 'blessed' by Microsoft.
Sometimes the simplest solution is the best, even if that means getting the user of my product to install SQL Express separately before running my install. Well, best for me, anyway :-)

- 399,467
- 113
- 570
- 794

- 854,327
- 234
- 1,573
- 1,953
-
Your example is truncated. The full code is here: http://www.experts-exchange.com/Programming/Installation/Q_23868626.html – dcraggs Nov 11 '09 at 12:51
-
Yeah, not sure what happened there. It *was* complete and, in fact, the links still worked, despite them not being in the edit box. This may be lost data from SO. In any case, we ended up using the other method so I've edited the answer - it's very simple to do and a lot safer than the other non-blessed solution. I also refuse to have to sign up with that site (and pay) you linked just to get solutions. SO's model is so much better. – paxdiablo Nov 11 '09 at 13:24
The following script will check for the full version of SQL Server 2008 R2. If full version is already installed, then it skips installing the SQL Server. If the full version is not installed, then it checks for the SQL Express edition. If it is already installed, it will skip the installation. If it is not installed, then it will install SQL Express 2008 R2.
Create a new script. Let's name it sql2008express.iss with the following content
[CustomMessages] sql2008r2expressx86_title=Microsoft SQL Server 2008 R2 Express Edition x86 (Including Tools) sql2008r2expressx64_title=Microsoft SQL Server 2008 R2 Express Edition x64 (Including Tools) sql2008r2expressx86_size=235.5 MB sql2008r2expressx64_size=247.5 MB [Code] const sql2008r2expressx86_url='http://download.microsoft.com/download/5/5/8/558522E0-2150-47E2-8F52-FF4D9C3645DF/SQLEXPRWT_x86_ENU.exe'; sql2008r2expressx64_url='http://download.microsoft.com/download/5/5/8/558522E0-2150-47E2-8F52-FF4D9C3645DF/SQLEXPRWT_x64_ENU.exe'; procedure sql2008express(); var version: string; begin // Check if the full version fo the SQL Server 2008 R2 is installed RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Microsoft SQL Server\SQLSERVER\MSSQLServer\CurrentVersion', 'CurrentVersion', version); if (version < '10.5') or (version = '') then begin // If the full version is not found then check for the Express edition RegQueryStringValue(HKLM, 'SOFTWARE\Microsoft\Microsoft SQL Server\SQLEXPRESS\MSSQLServer\CurrentVersion', 'CurrentVersion', version); if (version < '10.5') (*or (version > '9.00') or (version = '') *) then begin if isX64() then AddProduct('SQLEXPRWT_x64_ENU.exe', '/QS /IACCEPTSQLSERVERLICENSETERMS /ACTION=Install /FEATURES=SQL,AS,RS,IS,Tools /INSTANCENAME=SQLEXPRESS /SQLSVCACCOUNT="NT AUTHORITY\Network Service" /SQLSYSADMINACCOUNTS="builtin\Administrators" /INDICATEPROGRESS /TCPENABLED=1 /BROWSERSVCSTARTUPTYPE=Automatic /ERRORREPORTING=0 /SQMREPORTING=0 /SECURITYMODE=SQL /SAPWD=1234', CustomMessage('sql2008r2expressx64_title'), CustomMessage('sql2008r2expressx64_size'), sql2008r2expressx64_url,false,false) else AddProduct('SQLEXPRWT_x86_ENU.exe', '/QS /IACCEPTSQLSERVERLICENSETERMS /ACTION=Install /FEATURES=SQL,AS,RS,IS,Tools /INSTANCENAME=SQLEXPRESS /SQLSVCACCOUNT="NT AUTHORITY\Network Service" /SQLSYSADMINACCOUNTS="builtin\Administrators" /INDICATEPROGRESS /TCPENABLED=1 /BROWSERSVCSTARTUPTYPE=Automatic /ERRORREPORTING=0 /SQMREPORTING=0 /SECURITYMODE=SQL /SAPWD=1234', CustomMessage('sql2008r2expressx86_title'), CustomMessage('sql2008r2expressx86_size'), sql2008r2expressx86_url,false,false); end; end; end;
In your script then just include the script i nthe [Run] tag and call the previous created script in the [Code] tag like below:
[Run] `#include "scripts\sql2008express.iss" [Code] sql2008express();
Other notes: - If the setup kits for the SQL are found in the same folder then it will use them, if not, they will be downloaded from the Internet. - Sorry for the formating, it doesn't work. Copy/paste it in a text editor and format it. It is complete and working.
I hope this will help others too. :)

- 16,976
- 3
- 57
- 98

- 1,151
- 1
- 16
- 24
-
AddProduct doesn't seem to be recognised in InnoSetup - do you have a link to its iss file? – Mauro Jul 13 '15 at 09:02
-
1I think the code was extracted from this article. The answer is not complete. Should be down voted since it does not cite the original source. http://www.codeproject.com/Articles/20868/NET-Framework-1-1-2-0-3-5-Installer-for-InnoSetup – Eduardo Mauro Aug 13 '15 at 13:57
-
-
If the file "SQLEXPRWT_x64_ENU.exe" is found in the same folder it will be used at installation. If not, it will be downloaded in the current folder and then launched. – Alexandru Dicu Feb 24 '16 at 10:52