%0 is the program name as it was called,
%1 is the first command line parameter,
%2 is the second command line parameter,
and so on till %9.
The batch file's limitation to handle parameters up to %9 only can be overcome by using SHIFT.
After NT 4, we do not need to use SHIFT...
You can call this inside your batch file:
FOR %%A IN (%*) DO (
rem Now your batch file handles %%A instead of %1
)
%* will always expand to all original parameters, sadly. But you can use the following snippet of code to build a variable containing all but the first parameter:
:my_function
rem skip the first arag
shift
set args=%1
:my_loop
shift
if [%1]==[] goto my_end_loop
set args=%args% %1
goto :my_loop
:my_end_loop
rem Do somthing with the args
goto :EOF
You can call this inside your batch file:
call :my_function %*
No comments:
Post a Comment