Link to home
Start Free TrialLog in
Avatar of Perkentha1
Perkentha1

asked on

Append variables from one BATCH to another.

I need to carry over variables from one bat file to another for instance

Bat 1 executes

Echo.set /p var1:"questestion?" >> c:\temp.bat
echo. if /i "%var1%"=="answer" (goto:net) >> c:\temp.bat

Problem:  

echo. /i "%var1%"=="answer" (goto:net) >> c:\temp.bat
write out like this
if /i ""=="answer" (goto:net)
I need the %var1% to carry over too!
Avatar of knightEknight
knightEknight
Flag of United States of America image

change this:

   Echo.set /p var1:"questestion?" >> c:\temp.bat

to this:

   Echo.set /p var1="questestion?" >> c:\temp.bat
ASKER CERTIFIED SOLUTION
Avatar of SteveGTR
SteveGTR
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
That's one problem...

And to answer your question, use the escape character and don't use a colon in the gotos.

echo. /i "^%var1^%"=="answer" (goto net) >> c:\temp.bat
leew, I thought that would be correct, but it doesn't appear to work:

 /i "^"=="answer" (goto net)

Avatar of Perkentha1
Perkentha1

ASKER

I recieved the same results, %%var%% works,  I woulda have never thought to do that even though it did cross my mind.

Thanks for the help both of you!