Old 16th January 2007, 13:29   #1
kerstin
Junior Member
 
Join Date: Jan 2007
Posts: 5
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
kerstin is offline   Reply With Quote
Old 16th January 2007, 16:11   #2
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
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.

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 16th January 2007, 18:09   #3
kerstin
Junior Member
 
Join Date: Jan 2007
Posts: 5
Unfortunately your Links are timing out on me. Does anybody have an example what i like to accomplish?
kerstin is offline   Reply With Quote
Old 16th January 2007, 18:29   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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:
code:
SetOutPath $INSTDIR
File sql-installer.exe
ExecWait '"$INSTDIR\sql-installer.exe" /SILENT /USER=blah'


NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 16th January 2007, 19:28   #5
kerstin
Junior Member
 
Join Date: Jan 2007
Posts: 5
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
kerstin is offline   Reply With Quote
Old 16th January 2007, 19:32   #6
Red Wine
Forum King
 
Red Wine's Avatar
 
Join Date: Mar 2006
Location: Ath. GR
Posts: 2,078
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'

Quick AVI Creator - Quick and easy convert from DVD/MPEG/AVI/MKV to AVI/MP4/MKV
Quick AVI Creator entirely edited with NSIS and entirely upgraded to Unicode NSIS
Red Wine is offline   Reply With Quote
Old 16th January 2007, 21:06   #7
kerstin
Junior Member
 
Join Date: Jan 2007
Posts: 5
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?
kerstin is offline   Reply With Quote
Old 17th January 2007, 04:44   #8
Swapan Das
Senior Member
 
Join Date: Nov 2005
Location: Kolkata (Calcutta),India
Posts: 106
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,
Swapan Das is offline   Reply With Quote
Old 17th January 2007, 13:39   #9
kerstin
Junior Member
 
Join Date: Jan 2007
Posts: 5
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."
kerstin is offline   Reply With Quote
Old 10th September 2007, 14:30   #10
alexjula
Junior Member
 
Join Date: Sep 2007
Posts: 1
What's the actual link you used in :
NSISDL::download "link" ?
alexjula is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump