Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Is there a way to pass an argument from the dos prompt to a batch file. I'm wanting to do the following:
test.bat ARGUMENT
What do I need in the batch file to pick this up? Thanks in advance.

There's an easy way to do this.
Inside the batch file, DOS will automatically substitute %1, %2, %3, %4, %5, %6, %7, %8, and %9 with whatever was in ARGUMENT. It separates it into 1, 2, etc. by spaces, so if you did TEST.BAT A 3 BLAH, then %1 would be substituted with A, %2 would be 3, and %3 would be BLAH.Just put %1, %2, etc. just about anywhere in the batch file, just the way you see it - not in quotes or parentheses or anything, and the variables will be substituted.
Hope I helped...
-Chris

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

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