How to install SQL Server 2008 Express with Inno Setup?

ぐ巨炮叔叔 提交于 2020-05-10 03:37:53

问题


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?


回答1:


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 :-)




回答2:


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.

  1. 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;
    
  2. 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. :)



来源:https://stackoverflow.com/questions/454431/how-to-install-sql-server-2008-express-with-inno-setup

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!