The result will be the number of arguments:
set count=0 for %%a in (%*) do set /a count+=1
To get the last argument, you can do
for %%a in (%*) do set last=%%a
Note that this will crash if there are unbalanced quotes on the command line - the command line is reprocessed for , and not directly, using the parsing used for %1 , etc.
source share