BAT set multiple variables as one variable

Toshiba / Satellite a200
October 14, 2010 at 12:34:52
Specs: Windows 7 Home Premium, 2.5 ghz /2045 MB
Hello again, Fellow Computing.. ers
I have a problem with BAT.
I have mutliple variables and want to set them as one variable..
var1 contains: hello
var2 contains: large
var3 contains: world
set SUBR=%VAR1% %VAR2% %VAR3%
and now i want %SUBR% to be hello large world
i thought it would work but bat just says
"hello" is not a in....
for all three of them
does any1 know how (im sure u do!)

Thanks in advance, Rediwed

See More: BAT set multiple variables as one variable

Report •

October 14, 2010 at 13:42:33
C:\Users\Matt>SET Var1=Hello

C:\Users\Matt>SET Var2=Large

C:\Users\Matt>SET Var3=World

C:\Users\Matt>SET Var4=%Var1% %Var2% %Var3%

C:\Users\Matt>ECHO %Var4%
Hello Large World

You have to echo the variable. You cant just stick it in there and hope it reads your mind.

Can I put a question here?

Report •

October 15, 2010 at 06:14:30
Yes i know that... i did do the echo but it still didnt work...

Report •

October 15, 2010 at 14:19:11
Show me exactly what you have written. It's awfully hard to debug without seeing the script...

Can I put a question here?

Report •

Related Solutions

October 16, 2010 at 06:55:00
wel i did find out what was wrong..
but i cant fix it.
anyhow.. Here is the code:

Set /p appname=Please enter the app name:
set /p filename=Please enter the file name:
set /p folder=Please enter the folder name:
set /p message=And finaly a message (Optional):
echo %appname% %filename% %folder% %message%
:== Wel The problem is the line below this one

set output=echo_%appname%&_set_file=%filename%&_set_folder=%folder%&_set_msg=%message%

I:== I need a way to set the & sign into the %OUTPUT% variable
REM set output=%cod: =_%
echo Code Generated!!
echo %output%
echo Thanks!

If you know a way? (i thought of character codes but there don't seem to are any)

Thanks in advance Matt!!

Report •

October 16, 2010 at 09:59:03
In the future, When adding comments, use the REM command. Two colons (::) is also an option if you wish.

If you are wanting to use &, escape it with a caret (^).

ECHO Hello ^& Good bye.

However, I'm really sure that's what you are looking to accomplish.

set output=echo_%appname%&_set_file=%filename%&_set_folder=%folder%&_set_msg=%message%

When echoing %output% a few lines down, here's what you will get:


If this is what you wanted then ignore what I'm going to say next.

The variables will be replaced with what the user has set, but... I'm not understanding the purpose of this. Can I suggest you change it to:

set output=%appname% %filename% %folder% %message%

Can I put a question here?

Report •

Ask Question