Here's what I have so far and it's not working

Code: Select all
@echo off
if not %1 == "" (
set /A numIter=%~1
set /A ipAddress=%~2
set /A packetSize=%~3
) Else (
set /A numIter=1
set /A ipAddress=localhost
set /A packetSize=%RANDOM%
)
if %numIter% == 0 (
call :pingFlood %ipAddress% %packetSize%
) Else (
For /L %%G IN (1, 1, %numIter%) do (
start "Job %%G" "%~dpfx0" job%%G
:job%%G
call :pingFlood %ipAddress% %packetSize%
)
)
:pingFlood
ping %1 -t -l %2
The requirements that I have to meet are:
- Each iteration spawns a new cmd process
- The ping command accepts the IP address input as a parameter
- The ping command accepts a packet size input as a parameter
Currently when the batch file is executed without any parameters, I get the following output:
( was unexpected at this time.
When I add parameters e.g. "pingFlood 5 127.0.0.1 5000", I see the following behavior:
A cmd.exe process will spawn and I get the message "Missing operand." then it starts to ping 0.0.0.192 with the correct packet size.
The existing cmd.exe process shows the message "Missing operator." then it starts the same ping at the wrong address
Where have I gone wrong?