Hallo
before I go to my vacation they ask me if can send API to some web system because it was a lot of devices to send and my pc was not have powershell (not web pack) and not python so i develop "cmd as Multiprocessing" using curl.exe
what i did is send curl using cmd to the background and control how much "processing" i want running in the same time this was "creative" way to do it fast and finish the job and go to my vacation
to do it first all i cerate cmd the contains the bin of curl and what need he do
for example:
@ECHO off
curl.exe %1
timeout /T 1
why %1 ?
because i need send value as var to the background
after you save your first cmd script lets give it a name "demo.bat" and now we cerate the "main" cmd part
for this you need first all write "while read \ for i "
for example :
for /f "tokens=1 delims=" %%i in (list.txt) do call :part1 %%i
goto :fin
what is do ?
he take the list that contains the url\device what you need
and read every line until the end of the file
on this part
:part1
TASKLIST | find /c "cmd" >count.txt
set /p ch=<count.txt
set str1=%ch%
set /A fh=%str1%-1
IF %fh% GEQ 10 goto :wait
if he see have 10 cmd running he will go to "wait" and three i have sleep for 2 sec and check again
if not again he go to sleep 2 sec until i go down from 10 cmd if 1 will close the script will adding 1 more to keep all time 10 cmd runnig
START /B CMD /C CALL "demo.bat" %1 >NUL 2>&1
goto :eof
this line send the "demo.bat " to the background and keep do it until end of the file
:wait
timeout /T 2
goto :part2
block to send the script if you have 10 cmd running and back again to loop
:fin
echo done
last part is the "finish" to send the loop after reach to end of file.
you have full demo "POC"with ping you can download and play
summary:
in the bottom line instead to do one by one "http POST" and wait until the request finish (and go to the 2\3\4\5\ ...line) i send 10 requests in the same time and keep send it until i finish the file .
for example
if i was need send 100 http and lets say every request take 5 sec to finish (consider timeout) he will take long time
in my way like "multi threads" i send 10 http in the same time and if one of the 10 have timeout or take long time the others will runnnig and will finish (than i will adding more acording to the slot to keep 10 http request until end of the file )
and one note
I know English here is not perfect. But I'm dyslexic and it's part of my unique thinking :)