I have scripted NumbArguments.bat to easily determine the number of parameters passed to your script.

The syntax for using NumbArguments.bat is:

call NumbArguments Parms %*

where Parms is a call directed numeric environment variable that will contain the number of parameters (%*) passed.

Sample:

if your script (MyScript.bat) contains:
@echo off                              @echo %*                              call numbarguments num %*                              @echo %num%                              :: More statements
, typing MyScript AA BB CC DD would echo 4.

NumbArguments.bat contains:

                              @echo off                              if not exist "%TEMP%\NumbArguments.vbs" @echo Wscript.Echo WScript.Arguments.Count>"%TEMP%\NumbArguments.vbs"                              for /f "Tokens=*" %%a in ('cscript //nologo "%TEMP%\NumbArguments.vbs" %*') do (                               set /a %1=%%a - 1                              )