If all that is needed is to ping then just remove the outer loop and use the for statement.
FOR %%x IN (%*) DO ping %%x
If you need to do other things within that outside loop then just use the outer loop and the shift command while checking each iteration for an empty parameter.
@ECHO OFF
:loop_start
IF .%1==. GOTO end
ping %1
SHIFT
GOTO :loop_start
:end
Here is an example of running the latter solution although the output to both is identical. Note I did turn off echo and add a "-n 1" parameter to ping to keep the example output short.
C:\apps\Prod\85000026>tmp.bat 8.8.8.8 localhost 127.0.0.
Pinging 8.8.8.8 with 32 bytes of data:
Reply from 8.8.8.8: bytes=32 time=21ms TTL=52
Ping statistics for 8.8.8.8:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 21ms, Maximum = 21ms, Average = 21ms
Pinging MFGTESTFNTLSYS2 [::1] with 32 bytes of data:
Reply from ::1: time<1ms
Ping statistics for ::1:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
Pinging 127.0.0.1 with 32 bytes of data:
Reply from 127.0.0.1: bytes=32 time<1ms TTL=128
Ping statistics for 127.0.0.1:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms