Un setup creato con Nullsoft installer che lancia l'installazione di slqexpress solo se non presente.
Ho specificato un po di opzioni che cmq si possono personalizzare (vedi ExecWait ... )
-
OutFile "SQLExpress2005Setup.exe"
-
-
Section
-
SectionEnd
-
-
Function .onInit
-
#installazione non visibile
-
SetSilent silent
-
-
# controllo presenza SQL Express 2005
-
Call CheckSqlExpress
-
-
ExecWait 'SQLEXPR_ITA.EXE /qb INSTANCENAME=SQLEXPRESS \
-
ADDLOCAL=SQL_Engine SECURITYMODE=SQL \
-
SAPWD=strpwd DISABLENETWORKPROTOCOLS=0'
-
SetOutPath "$DESKTOP"
-
-
#Start /wait <CD or DVD Drive>\servers\setup.exe /qb
-
#INSTANCENAME=<InstanceName>
-
#ADDLOCAL=All
-
#PIDKEY=<pidkey value with no "-">
-
#SAPWD=<StrongPassword>
-
#SQLACCOUNT=<domain\user>
-
#SQLPASSWORD=<DomainUserPassword>
-
#AGTACCOUNT=<domain\user>
-
#AGTPASSWORD=<DomainUserPassword>
-
#SQLBROWSERACCOUNT=<domain\user>
-
#SQLBROWSERPASSWORD=<DomainUserPassword>
-
FunctionEnd
-
-
Function CheckSqlExpress
-
-
Call CheckSqlExpressInstalled
-
Pop $0
-
StrCmp $0 1 found.SQLExpress2005 no.SQLExpress2005
-
found.SQLExpress2005:
-
MessageBox MB_OK "SQL Express 2005 è già installato."
-
abort
-
no.SQLExpress2005:
-
FunctionEnd
-
-
Function CheckSqlExpressInstalled
-
-
Push $0
-
Push $1
-
Push $2
-
Push $3
-
Push $4
-
Push $5
-
-
StrCpy $0 "0"
-
StrCpy $1 "SOFTWARE\Microsoft" ;registry entry to look in.
-
StrCpy $2 0
-
-
StartEnum:
-
EnumRegKey $3 HKLM "$1\Microsoft SQL Server" $2
-
-
#MessageBox MB_OK "EnumRegKey $3"
-
StrCmp $3 "" noSQL notEmpty
-
-
;Trovato qualcosa
-
notEmpty:
-
;Inizia per 'MSSQL.'.
-
StrCpy $4 $3 6 0
-
#MessageBox MB_OK "EnumRegKey $4"
-
StrCmp $4 "MSSQL." +1 goNext
-
-
ReadRegStr $5 HKLM "$1\Microsoft SQL Server\$3\Setup" "Edition"
-
StrCmp $5 "Express Edition" yesSQL goNext
-
-
#MessageBox MB_OK "ok: $5"
-
Goto noSQL
-
-
goNext:
-
;Vado alla prossima chiave.
-
IntOp $2 $2 + 1
-
goto StartEnum
-
-
noSQL:
-
#MessageBox MB_OK "NON trovato SQL Express 2005"
-
StrCpy $0 0
-
Goto done
-
-
yesSQL:
-
#MessageBox MB_OK "Trovato SQL Express 2005"
-
StrCpy $0 1
-
done:
-
Pop $5
-
Pop $4
-
Pop $3
-
Pop $2
-
Pop $1
-
;MessageBox MB_OK $0
-
Exch $0
-
-
FunctionEnd
-