Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
DOS command line arguments
Name: StephenJ Date: July 27, 2009 at 07:34:58 Pacific OS: Windows XP Subcategory: General
Comment:
Hi, how can I get all the DOS command line arguments in a single variable?
If I were pass the args as: temp.bat a b c d e f,
I want the assign all the args as a sentence in a single variable. e.g var1="a b c d e f"
Name: Mechanix2Go Date: July 27, 2009 at 07:42:25 Pacific
Reply:
set var=%1 %2 %3 %4 %5 %6
===================================== If at first you don't succeed, you're about average.
M2
0
Response Number 2
Name: StephenJ Date: July 27, 2009 at 09:07:49 Pacific
Reply:
I am sorry, I did not make it clear earlier that the number of arguments may not be the same every time. It could be 6 or 5 or 4. Is there a common variable that holds all the args similar to $? in Unix.
0
Response Number 3
Name: Mechanix2Go Date: July 27, 2009 at 09:14:01 Pacific
Reply:
I don't think so, but this:
set var=%1 %2 %3 %4 %5 %6
will work if there is no %5 %6 etc.
===================================== If at first you don't succeed, you're about average.
Summary: All right, you posted this question on both forums. I think the main reason OtheHill said that was because you have used a *wrong* title for your question. The title should for example be "NT command ...
Summary: The limit on a dos command line seems to be 128 characters. On unix, I use brackets { }for certain longer commands. Is there anyway to write a longer command line in DOS? (I'm running Win98)...