Archive: Silent Install of SQL with Parameters


Silent Install of SQL with Parameters
Hello,

i am very new to NSIS. I am just writing an installer which detects if SQL 2005 Express is installed on the computer. Now so the sql install window won't popup i would like to give it the path username and so on with it so the user does not have to get confused. i know you can install sql through commandline or an ini file but how can i accomplish this through my NSIS installer? Thank you


Since you know that you can install sql through commandline, you may pass the command line to built in commands such as Exec or ExecWait, or pass it to the included nsexec plugin. Also there are a couple of similar plugins at wiki ExecCmd for instance.


Unfortunately your Links are timing out on me. Does anybody have an example what i like to accomplish?


The links should be back again soon. SourceForge has some downtimes now and then. They do have a zillion hits a second, or so I'm told by the marketing guy behind me. But seriously, their service is great, even with the occasional downtime.

Anyway, back to your question, simply use ExecWait to run the installer. For example:

SetOutPath $INSTDIR
File sql-installer.exe
ExecWait '"$INSTDIR\sql-installer.exe" /SILENT /USER=blah'

Hmm,sorry don't wanna be annoying, but i tried your code and i do not know it just does not work i get error because only 1-2 parameters are expected but i got a lot more:

ExecWait '"$TEMP\SQLEXPR.EXE"' /Silent /INSTANCENAME=SQLEXPRESS ADDLOCAL=All PIDKEY=ABCDE12345FGHIJ67890KLMNO SAPWD=StrongPassword SQLACCOUNT=SQLEXPRESS\bla SQLPASSWORD=blabla AGTACCOUNT=SQLEXPRESS\bla AGTPASSWORD=blabla SQLBROWSERACCOUNT=sqlexpress\bla SQLBROWSERPASSWORD=blabla '
I just do not have a single clue what i need to do. if i use the ExecCmd::exec i also get an error (not supported even so i have put the dll to the plugins)

Thank you for all your help


Be aware of the quotes, that's probably the problem.

ExecWait '"$TEMP\SQLEXPR.EXE" /Silent /INSTANCENAME=SQLEXPRESS ADDLOCAL=All PIDKEY=ABCDE12345FGHIJ67890KLMNO SAPWD=StrongPassword SQLACCOUNT=SQLEXPRESS\bla SQLPASSWORD=blabla AGTACCOUNT=SQLEXPRESS\bla AGTPASSWORD=blabla SQLBROWSERACCOUNT=sqlexpress\bla SQLBROWSERPASSWORD=blabla'


hey thank you for your fast reply- yup the quotes where the issue. no i got it to compile but when i have the installer running and it comes to the sectin where it should install the sql express then it runs through half of my installation then errors out (Microsoft discovered blabla). Any idea? Anybody out there with experience with silent install of sql express?


In near future I may have to build such an installer, so I'm looking forward to this thread for a solution.

Kerstin, for MSDE/SQL Serve detection you may refer to my thread:
http://forums.winamp.com/showthread....hreadid=261330
(for final coding)

http://forums.winamp.com/showthread....hreadid=261052
(for discussion)

I've not yet checked the registry for SQL 2005 Express. Hope it will be the same, otherwise you've to just replace that registry path.

Now coming to your execution of SQL installation:
Since I was installing SQL only if there is no existence of SQL, the coding was simple:

ExecWait '"$INSTDIR\setup.exe"' $0
(yes, no silent installation)
I called it from Finish page Run, so it was fine for the user also.

But to throw some light on how to call a SQL script, I'm providing you a script of how to restore a SQL database from NSIS installer. I've created a text file containing the actual command and then calling it.

Function RestoreSQLData
SetOverwrite try
nsExec::Exec "cmd /C NET START MSSQLSERVER"
StrCpy $DemoDbName "Demo"
SetOutPath "$INSTDIR"
SetFileAttributes "$INSTDIR\Data\$DemoDbName.bak" NORMAL
FileOpen "$0" "RestDemo.txt" "w"
FileWrite "$0" "RESTORE DATABASE $DemoDbName FROM DISK='$INSTDIR\Data\$DemoDbName.Bak' WITH MOVE 'Data_dat' TO '$INSTDIR\Data\$DemoDbName.mdf',MOVE 'Data_log' TO '$INSTDIR\Data\$DemoDbName.ldf',REPLACE$\r$\n"
FileClose "$0"
nsExec::Exec "cmd /C Osql -S . -U sa -P -o Demo.Log -i RestDemo.txt"
FunctionEnd

Demo.log will contain the output. You can check from here whether your command executed properly or not.

This is not actually what you want, but may be helpful.
If you get it right meantime, then do let us know.

With regards,


Thank You so much for your help! i got it in the meantime.
Here is a snippet of what i ended up doing:
NSISDL::download "http://example.com/admin/SQLEXPR.EXE" "$TEMP\SQLEXPR.EXE"
ExecWait '$TEMP\SQLEXPR.EXE /qb INSTANCENAME=bla ADDLOCAL=ALL SECURITYMODE=SQL SAPWD=bla DISABLENETWORKPROTOCOLS=0'
SetOutPath "$INSTDIR"
File "\Mule Worker Debug\mule2_db.exe"
ReadRegStr $0 HKLM "System\CurrentControlSet\Control\ComputerName\ActiveComputerName" "ComputerName"
ExecWait 'mule2_db.exe /server:$0\bla /database:bla /username:bla /password:bla /makedatabase'
DetailPrint "Completed SQLServer 2005 install. Cleaning temporary files..."
Delete "$TEMP\SQLEXPR.EXE"
DetailPrint "Completed cleaning temporary files."


What's the actual link you used in :
NSISDL::download "link" ?