1.

Solve : batch file % variable?

Answer»

1)In a batch file command i see this:

%1

what is it?

it was WRITTEN that:

The percent FOLLOWED by a NUMERIC value, BEGINNING with one, allows users to add variables within a batch file. The following is a batch file example:
echo Hello %1


i didn't understand the meaning. Pls explain. What does it mean by a variable?

2) also it was written " This can be extended to %2, %3, and so on"

How to do that???

Thanks in advance.


Actually the variables %0 THRU %9 are values that are passed along the command line when running a command or file.

%0 is always the name of the command or file you're running

Ex: copy frompath\filename.ext topath\filename.ext

%0 = copy (the name of the file or command)
%1 = frompath\filename.ext
%2 = topath\filename.ext

There is also a SHIFT command that allows you to manipulate the values and extend them beyond %9.

Check out: http://www.chebucto.ns.ca/~ak621/DOS/DOS-Var.html

Hope this helps.



Discussion

No Comment Found