1.

Solve : Use Arguments in Batchfile!!!?

Answer»

Hello,
i just want SOMEONE to shed something about arguments being used in Batch file, i am not able to get a firm grip on this thing, i have downloaded many doc files and copy pasted materials from the web but it only revolvs around the same thing and thier is no full proof material to full one's querie. So i am requesting from this forum, to shed some light on this subject: beggining with a small example and extending it little by little.

Thank you:
When you start any windows PROGRAM, you can pass what are called 'arguments,' which are small pieces of data. You can tell a paint program what file to OPEN, for example. In batch files, you access the arguments with %1, %2, %3, etc.

Let's SAY you have a batch file called echoarg.bat, which contains one line:
Code: [Select]echo %1
When you type
Code: [Select]echoarg exampletext 2ndarg arg3into the command line, you will see exampletext appear on-screen. In this example, %2 will be "2ndarg" and %3 will be "arg3", but the batch file doesn't use those.

Hope this helps some, just ask if this needs more clarification.just a clarification on what TechnoGeek posted.

Say you have a batch file NAMED arg.bat that looked like this:
Code: [Select]@echo off
echo %1
echo %2
echo %3

and you called it like so:
Code: [Select]arg.bat A B C

it would compile as such:
Code: [Select]@echo off
echo A
echo B
echo C

with an output of:
Code: [Select]A
B
C

WARNING, if you were to call the arg.bat program above like so:
Code: [Select]arg.bat A B

it would compile as
Code: [Select]@echo off
echo A
echo B
echo

which would output as:
Code: [Select]A
B
echo is off.

I would recommend using 'echo.%1' to fix this issue.



Discussion

No Comment Found