Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Passing more than 10 arguments via batch files

960 views
Skip to first unread message

anan...@my-deja.com

unread,
Dec 21, 1999, 3:00:00 AM12/21/99
to
Is there a way I can use batch files to execute a programs that requires
me to pass more than 9 command line arguments?

The way I know limits me to passing only upto 9 args.

<prog name> %1 %2 %3 .... %9

Any help would be appreciated.

-Anand


Sent via Deja.com http://www.deja.com/
Before you buy.

l...@bounceall.net

unread,
Dec 21, 1999, 3:00:00 AM12/21/99
to

Why not have the program parse the entire command line internally?

Have user use commands like DOS does /xxx /yyy /zzz then the program can
easily look for /xxx /yyy /zzz etc.

LB

Tom Lavedas

unread,
Dec 21, 1999, 3:00:00 AM12/21/99
to
anan...@my-deja.com wrote:
>
> Is there a way I can use batch files to execute a programs that requires
> me to pass more than 9 command line arguments?
>
> The way I know limits me to passing only upto 9 args.
>
> <prog name> %1 %2 %3 .... %9
>
> Any help would be appreciated.
>
> -Anand
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.

This is easily done with the SHIFT statement and an environment
variable. Assuming there is sufficient environment space available it
can be as simple as ...

@echo off
set _Tmp=%1
:Loop
if not '%2==' set _Tmp=%_Tmp% %2
shift
if not '%2==' goto Loop
<prog name> %_Tmp%
set _Tmp=

Another way in Win95/98/NT to do this is to enclose all of the arguments
in double quotes. For example, consider the set of arguments "a b c d e
f g h i j". All ten of these arguments can be passed as ...

yourbatch "a b c d e f g h i j"

and used as as a single input argument ...

for %%v in (%1) do <prog name> %%v

The FOR statement strips off the double quotes.

Tom Lavedas
-----------
http://www.pressroom.com/~tglbatch/

Ted Davis

unread,
Dec 21, 1999, 3:00:00 AM12/21/99
to
On Tue, 21 Dec 1999 07:45:41 GMT, anan...@my-deja.com wrote:

>Is there a way I can use batch files to execute a programs that requires
>me to pass more than 9 command line arguments?
>
>The way I know limits me to passing only upto 9 args.
>
><prog name> %1 %2 %3 .... %9
>
>Any help would be appreciated.
>
>-Anand
>
>

It is *extremely* important to state what operating system you want
solutions for. In this case the solution for NT (which you posted
from) is two characters, while otherwise it is several lines. In NT

%*

is the entire command tail: all the arguments given to the batch file.

T.E.D. (tda...@gearbox.maem.umr.edu)
SPAM filter: Messages to this address *must* contain "T.E.D."
somewhere in the body or they will be automatically rejected.

Outsider

unread,
Dec 21, 1999, 3:00:00 AM12/21/99
to
anan...@my-deja.com wrote:
>
> Is there a way I can use batch files to execute a programs that requires
> me to pass more than 9 command line arguments?
>
> The way I know limits me to passing only upto 9 args.
>
> <prog name> %1 %2 %3 .... %9
>
> Any help would be appreciated.
>
> -Anand

@ECHO off
:: code here to handle first 9 parameters
::
FOR %%N IN (1 2 3 4 5 6 7 8 9) DO SHIFT
IF not "%1"=="" ECHO parameter 1 is now %1
IF "%1"=="" ECHO no parameter 1

--
Regards,
Outsider
'From' address is nonvalid, use 'Reply-To' address.
MS-DOS 6.22, Windows for Workgroups 3.11, Netscape Navigator 4.08

0 new messages