Archive: What's wrong with my code? (MSDE, osql)


What's wrong with my code? (MSDE, osql)
I'm making installer that needs to install MSDE, start service and then run a script to make a database and fill it with data.
I test and create a code on a same computer using multiboot (primary C: for coding , secondary D: for testing). Both are WinXP SP2, secondary has almost nothing installed (os, drivers, winrar, av & trueimage so I can have a clean system in 10mins).

So far my code is:
...
ExecWait '"MSDE2000A\Setup.exe" /wait /qn+ SAPWD=$DBPASS INSTANCENAME=BLA SECURITYMODE=SQL'
...
ExecWait "net start MSSQL$BLA"
...
SetOutPath $INSTDIR
File script.sql
...
ExecWait '"osql -U $DBUSER -P $DBPASS -S $COMPNAME\BLA -i $INSTDIR\script.sql -o $INSTDIR\script.rpt"' $0
...
That last line is problem.

If run on a clean system (secondary) it installs msde, runs service and fails to execute script.
If I try it in command prompt everything is fine (I've put a bunch of messageboxes so I can check what has happend). I'm sure it something silly but after hours of testing I just don't see it.
HELP PLEASE?


You probably need to put the path in as well as the extension.

; Read the path for osql, put it in $1
ExecWait '"$1\osql.exe" -U $DBUSER -P $DBPASS -S $COMPNAME\BLA -i $INSTDIR\script.sql -o $INSTDIR\script.rpt' $0


Hmm...
Thanks for that fast reply.

Don't think that is the problem since in earlier version I used:

ExecWait "scm.exe -Action 1 -Service MSSQL$BLA -silent 2"

instead of

ExecWait "net start MSSQL$BLA"

and it worked. AFAIK both scm.exe and osql are part of msde.
Still, its worth a try.


Have you spaces in $INSDIR? If so you shuld put it in quotes.
Consider using nsExec::ExecToLog instead of execwait so to get the output of OSQL and check it
Consider also to replace OSQL with MSSQL_OLEDB plugin


Thanks for all your help.
It worked!
Problem was in paths just like JasonFriday13 said:
After testing, code now looks like:
...
ExecWait "$UTILPATH\scm.exe -Action 1 -Service MSSQL$BLA -silent 2"
...
ExecWait '"$UTILPATH\osql" -U$DBUSER -P $DBPASS -S $COMPNAME\BLA -i $INSTDIR\1_Tables.sql -o $INSTDIR\1_Tables.rpt' $0
...

sgiusto, I've considered using your plugin but decided not to because off:

Excecutes a SQL query contained in a file
<scriptfile> - Path to file containing the script to execute (max 60000 bytes)
In final version of installer I have 4 scripts totaling 2.75MB :D