Archive: SQL Server Configuration


SQL Server Configuration
Hi,

I have been developing an installer with NSIS over the past month. I am currently working on a page to test if SQL Server is installed. I have successfully tested it and it skips the page if it isn't installed but my problem is when it is installed I want to display a list of servers which are running on the application. I would like it if I could display them in a listbox and allow the user to click on one of them.

I am currently using an 'osql' command shown below and am trying to get to write the contents to the stack then read it off and print it to the listbox. Currently I am only getting 1 line returned from the command which happens to be the first line of the command prompt.

ReadRegStr $R1 HKLM "SOFTWARE\Microsoft\Microsoft SQLServer\80\Tools\ClientSetup" "SQLPath"

nsExec::ExecToStack cmd /C "$R1\Binn\osql.exe" -L

Could anyone direct me to where I am going wrong or a better way of achieving what I am trying to do.


you could try to redirect the output to a file and parse that instead:
nsExec::ExecToStack cmd /C "$R1\Binn\osql.exe" -L > $temp\servicelist.txt (or someting like that)


NSIS 2.11 nsExec Readme:
To ensure that command are executed without problems on all windows versions,
is recommended to use the following syntax:

nsExec::ExecToStack [OPTIONS] '"PATH" param1 param2 paramN'

This way the application path may contain non 8.3 paths (with spaces)
And you probably can scip cmd /C or use code below to keep Win vers compatibility


ReadEnvStr $0 COMSPEC
nsExec::ExecToStack '$0 /C "$R1\Binn\osql.exe" -L'

Do not forget to test this on Win2003 server.

Reformat
Thanks for the quick reply. I have changed the formatting of the line so that now (once it creates the line from the different sources) it tries to run

c:\windows\system32\cmd.exe /C "c:\program files\Microsoft SQL Server\80\Tools\Binn\osql.exe" -L

This successfully works on the command prompt but when I check the stack it now doesn't contain anything.


Anders,

Thanks for the suggestion about the cmd --> file --> form. I had considered this but hoped I wouldn't have to use it.


BTW ExecDos has parameter for stdout file


ExecDos::exec '"$R1\Binn\osql.exe" -L' '' '$EXEDIR\osql.log'