Getting command line arguments from .BAT (batch) scripts.

When wrapping commands in BAT scripts in DOS, I've often found it useful to allow for any number of arguments to be passed in to the wrapped command. Here's a quick snippet I found in the Apache Tomcat startup scripts that loops through the arguments entered on the command line, appending them to a variable (CMD_LINE_ARGS).

@echo off
 if ""%1""=="""" goto doneSetArgs
 goto setArgs

Or simply wildcarding the input (%*) might do the trick. For example, if I wanted to wrap a particular version of JavaC in a bat script, I might write something like this:

@echo off
C:\j2sdk-1_3_2_05\bin\javac %*
Allowing me to invoke it with any valid set of args for JavaC: javac13.bat -verbose -classpath %FOOPATH% -d ../build