Here are two ways to do this:
First this rather simple example, uses the for command:
@echo off set argc=0 for %%G in (%*) do set /a "argc = %argc + 1" echo Count is %argc% echo Args are %* goto :eof
Next this rather more convoluted technique calls a subroutine that counts arguments:
@echo off call :count_arg argc %* echo Count is %argc% echo Args are %* goto :eof :: Function :count_arg Arg1 [Arg2] ... [ArgN] :: Arg1 = Variable name (to store the count in) :: Arg2 ... ArgN optional list of zero to N items :count_arg set var_name=%1 set /a "%var_name% = 0" :count_loop if not [%2]==[] ( shift set /a "%var_name% = %var_name% + 1" goto :count_loop ) set var_name= goto :eof
G. Patterson.   T/A PGTS ABN: 99885392845