Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Ok, this surely is dumb, but what is "%1", "%start%" and "%%f" all these stuffs? I tried to read some tutorials, but they never tell me what are those stuffs and start using it in the tutorial. Thanks for your help.

When you start a batch file, you can pass it a series of parameters. Each parameter is a text string separated by spaces. How do you access these parameters within the batch file? The "%1" in the batch file gets replace by the string of the first parameter. "%2" gets replaced by the string of the second parameter, and so on through "%9". In addition, the "%0" parameter gets replace by the batch file name.
So if you have MYBATCH.BAT and enter:
MYBATCH IS A good one
%0 = MYBATCH
%1 = IS
%2 = A
%3 = good
%4 = one
%5 through %9 have a null string value.So if in the batch file you have:
ECHO %3%4
It gets replaced by ECHO goodone and the ECHO command displays "goodone".
So how do you enter more than nine parameters? There is also a SHIFT command, that when executed shifts each of the input parameters left one and discards the first one. So that the values become:
%1 = A
%2 = good
%3 = one
%4 through %9 have a null string value.And then you could SHIFT it again.
In addition there are a list of Environment variables that have names and a text string associated with it. You can display the current ones with a SET command. In addition you can change or add one to the environment with the SET command:
SET TESTVALUE = TEST
In a batch file, you can access the strings in the environment, in this case the "%TESTVALUE% has the value and gets replaced with the string "TEST". So in this case a batch file line of:
ECHO %3%TESTVALUE%
displays goodTEST
Now %%f and %f are variables you define within the batch file, where the "f: is any alphabetic character(s). You assign a string value to the %%f (or a series of string values) and in the rest of the statement the %f gets replaced by the string.

also if you are a beginner a good site to visit would be www.computerhope.com and www.robvanderwoude.com (i hope i spelt that right) :)
btw:microsoft gives some surprisingly useful information by typing in command.com "(command) /?" I'm sure you already new this but just in case.

Thanks, JackG and Nathan, that' really helpful, especially the reply about the parameters. Btw, maybe I din check clear enough, but http://www.robvanderwoude.com is one of those site who starts using %1 ...etc without explaining it. =)
I have another question, is there any other method to accept user inputs from user except CHOICE? Can a batch prompt and accept strings like "MYBATCH IS A good one"? Thanks again.

depends if windows ME supports the "set /p" command. goto start>run>cmd
then type "set /?" if there is nothing in there about the "/p" in there then i dont know what to tell you.

sorry about my previose post i just wanna say i found something at www.batch.hpg.ig.com.br leonardo's web site. SOME GREAT STUFF THERE

yeah, no info about set /p there.
Also, I'd already checked Leonardo's website. But the stuffs there's a bit too hard for someone who know lil about batch scripting like me.
I just want to know a simple command that accepts string input, like scanf or gets in C. Help me please. I just need it to write a very simple batch.

The ONE thing i can think of is finding someone who has win xp and stealing their set.com file. :)
another sulotion would be to get rid of ME. (I NEVER LIKED IT)
if you ask me the emulated dos is better, I know alot of people will go the other way on that.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |