Set command help

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
dachadster13
Posts: 5
Joined: 20 Jul 2009 17:19

Set command help

#1 Post by dachadster13 » 20 Jul 2009 17:36

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.

ghostmachine4
Posts: 319
Joined: 12 May 2006 01:13

#2 Post by ghostmachine4 » 20 Jul 2009 17:40

what is the actual problem you are trying to solve?

dachadster13
Posts: 5
Joined: 20 Jul 2009 17:19

#3 Post by dachadster13 » 20 Jul 2009 18:04

@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?

ghostmachine4
Posts: 319
Joined: 12 May 2006 01:13

#4 Post by ghostmachine4 » 20 Jul 2009 18:53

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.

dachadster13
Posts: 5
Joined: 20 Jul 2009 17:19

#5 Post by dachadster13 » 20 Jul 2009 19:03

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.

dachadster13
Posts: 5
Joined: 20 Jul 2009 17:19

#6 Post by dachadster13 » 20 Jul 2009 19:43

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.

Post Reply