Just try to invert the commands using pipe:
// replace
command | timeout
// per
timeout | command
@echo off
set /a maxLoop=999999
set /a loopCount=%maxLoop%
for /l %%x in (1, 1, %maxLoop%) do (
timeout 21600 | call c:\rclone\rclone1.bat
wmic process where name="rclone1.exe" call terminate >nul
timeout 21600 | call c:\rclone\rclone2.bat
wmic process where name="rclone2.exe" call terminate >nul
timeout 21600 | call c:\rclone\rclone3.bat
wmic process where name="rclone3.exe" call terminate >nul
timeout 21600 | call c:\rclone\rclone4.bat
wmic process where name="rclone4.exe" call terminate >nul
set /a loopCount=%loopCount%-1
if "%loopCount%"=="0" GOTO :EOF
)
To prevent the output strings of the timeout
command redirected in the console after the execution of the called bat is finished from appearing on the console screen, use >nul 2>&1
:
@echo off
set /a maxLoop=999999
set /a loopCount=%maxLoop%
for /l %%x in (1, 1, %maxLoop%) do (
>nul 2>&1 timeout 21600 | call c:\rclone\rclone1.bat
wmic process where name="rclone1.exe" call terminate >nul
>nul 2>&1 timeout 21600 | call c:\rclone\rclone2.bat
wmic process where name="rclone2.exe" call terminate >nul
>nul 2>&1 timeout 21600 | call c:\rclone\rclone3.bat
wmic process where name="rclone3.exe" call terminate >nul
>nul 2>&1 timeout 21600 | call c:\rclone\rclone4.bat
wmic process where name="rclone4.exe" call terminate >nul
set /a loopCount=%loopCount%-1
if "%loopCount%"=="0" GOTO :EOF
)
What I would do in an equality scenario and without using variables, but using my personal preferences, the code would be:
@echo off
for /l %%i in =;(999999, -000001, 000001)do @for /l %%y in =;(01, 01, 04)do =;(
>nul 2>&1 timeout 21600 | start /b "" cmd.exe /r "c:\rclone\rclone%%y.bat"
<con: call wmic process where name="rclone%%y.exe" call terminate >nul );=
If the intention is to wait for the call
+ timeout
command to complete and only after that you need to force the rcloneX.exe
executable to terminate, I would try to use:
@echo off
for /l %%i in =;(999999, -000001, 000001)do @for /l %%y in =;(01, 01, 04)do =;(
cmd.exe /v /q /r ">nul 2>&1 timeout.exe 2160 | "c:\rclone\rclone%%~y.bat""
<con: call wmic process where name="rclone%%y.exe" call terminate >nul );=