Page 1 of 1

Set command help

Posted: 20 Jul 2009 17:36
by dachadster13
I am working on a batch script and am having trouble with the set command. I have looked in the help section of the command but am still missing something (probably simple). Here is what I have so far:

@echo off
echo Program Name: = %0
set %1 =%test%
echo Argument 1 =%1
echo Argument 2 =%2
echo Argument 3 =%3

I read this and think that Argument 1 will populate with test but I get a syntax error which is an improvement from the nothing I was getting earlier. If I can get some direction to correcting this it would be greatly appreciated. Thanks all in advance.

Posted: 20 Jul 2009 17:40
by ghostmachine4
what is the actual problem you are trying to solve?

Posted: 20 Jul 2009 18:04
by dachadster13
@echo off
echo Program Name: = %0
set %1 =%test%
echo Argument 1 =%1
echo Argument 2 =%2
echo Argument 3 =%3

I am trying to output the test variable to the Argument 1 line. Or do I have this completely jacked up?

Posted: 20 Jul 2009 18:53
by ghostmachine4
where does your %test% variable come from? why is there a need to change %1 in your script? you can just pass the correct variable to the batch file when invoking it. I can't really understand what you are trying to do.

Posted: 20 Jul 2009 19:03
by dachadster13
I am reading the help from the cmd prompt and it says the syntax is
set variable = string. I am interpreting this as I am giving the string a value. So when I type the string portion, it returns the variable. Sorry for the poor example. I have never needed to know how to use this command before. Variables are new to me.

Posted: 20 Jul 2009 19:43
by dachadster13
Sorry for all the confusion. After playing around with it some more I got the answer.I was pretty much just testing how the command functioned and my syntax was off. Thanks.