PDA

View Full Version : Run Command Line and variables



NewsArchive
11-15-2007, 03:04 AM
I have an install script which installs our app as well as SQL express. I
am using Run Command Line twice, neither of which appears to be working.

At the beginning of the install, I am checking to see if express is already
installed, and if so, is my instance there (hence, update). I am using bcp
to get a list of instances as follows:

Run Command Line
bcp "SELECT name FROM sys.Databases WHERE name = '%TP_DBNAME%'" queryout
%TMPDIR%\TCS_DBlist.txt -c -U %TCS_SQL_LOGIN% -P %TCS_SQL_PWD% -S
%PC_NAME%\%INSTANCENAME%
(x) wait for program

Once the complete installation is done, I am trying to update a record in
the database to "activate" everything as follows: (had to break it up,
because run field is not big enough to hold all the text)

Set Variable %SQL_CMD_PRE%
-U "%TCS_SQL_LOGIN%" -P "%TCS_SQL_PWD%" -S "%PC_NAME%\%INSTANCENAME%" -d
"%TP_DBNAME%" -o "%_SB_INSTALLDIR%\TCS_DBreg.txt"

Set Variable %SQL_CMD_SUF%
-Q "update Registration set
REG_SerialNumber='0000000000',REG_MembershipNumber ='0000000000' WHERE
REG_SiteID='1'"

Run Command Line
sqlcmd %SQL_CMD_PRE% %SQL_CMD_SUF%
(x) wait for program

Both of these display messages so I can see that all the vars are being set
properly, and they are. I even wrote out the resulting commands to txt
files, so I could run them myself, and they work flawlessly from the Windows
CMD prompt.

I put the resulting commands in an INI (so I could edit them) along with the
%_SB_ERRORCODE% generated.
Here are the two lines, with their error codes:

bcp "SELECT name FROM sys.Databases WHERE name = 'TirePower-Demo'" queryout
C:\DOCUME~1\ADMINI~1.TCS\LOCALS~1\Temp\TCS_DBlist. txt -c -U ####### -P
####### -S TCS_TEST_01\TCS_SYSTEMS
Error=1

sqlcmd -U "########" -P "########" -S "TCS_TEST_01\TCS_SYSTEMS" -d
"TirePower-Demo" -o "C:\Program Files\Tire Company Solutions\Tire Power
Demo\TCS_DBreg.txt" -Q "update Registration set
REG_SerialNumber='0000000000',REG_MembershipNumber ='0000000000' WHERE
REG_SiteID='1'"
Error=1


Glenn Paschal

NewsArchive
11-15-2007, 03:06 AM
UPDATE: Appears to be related to the variables.
They don't seem to be evaluated before sent to command line.

Glenn Paschal

NewsArchive
11-15-2007, 03:08 AM
Glenn

>I have an install script which installs our app as well as SQL express. I
>am using Run Command Line twice, neither of which appears to be working.
>
>Run Command Line
>bcp "SELECT name FROM sys.Databases WHERE name = '%TP_DBNAME%'" queryout

I think you need to specify the full drive:pathname\bcp.exe ....... for bcp and
sqlcmd.

I added a variable for the path to them, added a searchForFile to locate the BINN
folder path, then it all worked. And yes, you will need a variable to hold a long
list of commandline parameters. works great.

JohnG

NewsArchive
11-15-2007, 03:08 AM
Glenn,

Exactly what John said. You have to specify the full
drive:pathname\bcp.exe.

Friedrich

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

"point. click. ship" - that's SetupBuilder 6.6
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
11-16-2007, 02:44 AM
Hmm... Ok, this is just weird.
I created a small SB process that did only these two command line runs.
It worked flawlessly.
(and, this was before I got the message about the full paths)

To be sure that wasn't giving me problems, I got the path for BINN folder
from the registry, and tacked it to the front.
Still ran successfully in the test app.

I deleted these lines in my real install, coppied the lines from the test
install, and pasted them into the real install - in case i had some stupid
typo or something in the real one (even though I've NEVER done that
before...;)

Well, the reall install still doesn't work. Is it possible that the
uninstall log is causing me problems? or some other timing?

Thanks,
-Glenn.

NewsArchive
11-16-2007, 02:45 AM
Glenn,

> Hmm... Ok, this is just weird.
> I created a small SB process that did only these two command line runs.
> It worked flawlessly.
> (and, this was before I got the message about the full paths)
>
> To be sure that wasn't giving me problems, I got the path for BINN folder
> from the registry, and tacked it to the front.
> Still ran successfully in the test app.
>
> I deleted these lines in my real install, coppied the lines from the test
> install, and pasted them into the real install - in case i had some stupid
> typo or something in the real one (even though I've NEVER done that
> before...;)
>
> Well, the reall install still doesn't work. Is it possible that the
> uninstall log is causing me problems? or some other timing?

If it runs in your "test" install but not in the "real" install then there
must be a (minor) difference.

Perhaps your real install sets the "current folder" and, bang, Windows
cannot find the command line tool any longer. IMO, the fully qualified
pathname for the command line tool should help.

- Instead of

sqlcmd

- use

c:\correct_path_goes_here\sqlcmd.exe

Friedrich

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

"point. click. ship" - that's SetupBuilder 6.6
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
11-16-2007, 02:46 AM
I did that. "... To be sure that wasn't giving me problems, I got the path
for BINN folder from the registry, and tacked it to the front...."

And to be sure there wasn't a difference in the lines, I coppied them from
one to the other.

I understand that there is a difference, I'm just trying to figure out where
to look. There is no difference in the command. I coppied vars,
definitions, everything.

Glenn Paschal

NewsArchive
11-16-2007, 02:47 AM
Glenn,

> I did that. "... To be sure that wasn't giving me problems, I got the
> path for BINN folder from the registry, and tacked it to the front...."
>
> And to be sure there wasn't a difference in the lines, I coppied them from
> one to the other.
>
> I understand that there is a difference, I'm just trying to figure out
> where to look. There is no difference in the command. I coppied vars,
> definitions, everything.

If you are interested, you can send the .sb6 project to support (at)
lindersoft (dot) com. Perhaps we can find out where the difference is.
Please also send your "test" .sb6 project.

But this might take 12-18 hours. It's a very busy day today...

Friedrich

--
Friedrich Linder
Lindersoft
www.lindersoft.com
+1.954.252.3910

"point. click. ship" - that's SetupBuilder 6.6
Create Windows Vista ready installations in minutes

-- Official Comodo Code Signing and SSL Certificate Partner

NewsArchive
11-16-2007, 02:47 AM
I will work on it a bit more, see if I can figure it out, but I may take you
up on that.
Thanks for your help.
-Glenn.

NewsArchive
11-20-2007, 03:14 AM
Figured it out. Turns out, the path has to be in quotes, as well as the
options.

Thanks to everyone for their help.

-Glenn.

NewsArchive
11-20-2007, 03:14 AM
Hi Glenn,

Cool! Thanks for the update.

Friedrich