-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcheckSqlServer.iss
34 lines (32 loc) · 1.08 KB
/
checkSqlServer.iss
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[Code]
function IsSqlServerInstalled(): Boolean;
var
sqlserverInstalled: Boolean;
Version: String;
PackedVersion: Int64;
begin
RegQueryStringValue(HKLM, ExpandConstant('SOFTWARE\Microsoft\Microsoft SQL Server\{#ServerInstance}\MSSQLServer\CurrentVersion'), 'CurrentVersion', version);
if (version < '10.5') (*or (version > '9.00') or (version = '') *) then
sqlserverInstalled := false
else
sqlserverInstalled := true;
Result := sqlserverInstalled;
end;
procedure InstallSqlServer;
var
ResultCode: Integer;
Params: String;
begin
Params := '/ACTION="Install" ' +
'/Q ' +
'/FEATURES=SQL ' +
ExpandConstant('/INSTANCENAME="{#ServerInstance}" ') +
'/HIDECONSOLE ' +
'/IACCEPTSQLSERVERLICENSETERMS ';
if not ShellExec('', ExpandConstant('{src}\Bin\SQLEXPR_x86_ENU.exe'),
Params, '', SW_SHOW, ewWaitUntilTerminated, ResultCode) then
begin
MsgBox('Microsoft SQL Server 2008 R2 - Express Edition installation failed with code: ' + IntToStr(ResultCode) + '.',
mbError, MB_OK);
end;
end;