(Batch) For 循环

@echo off

for /l %%i in (1,1,5)  do ( 

    tasklist /fi "imagename eq sysprep.exe" | find /i "sysprep.exe" 

    if not errorlevel 1 ( 

        taskkill /F /IM "sysprep.exe" 

        if errorlevel 0 goto :NEXT

    )

    echo Retry to terminate sysprep process... %%i 

    if %%i EQU 5 goto :SHUTDOWN

    ping 1.0.0.0 -n 1 -w 6000 > nul 

)



:NEXT

echo 1



echo 2



echo 3



:SHUTDOWN

echo shutdown

 

你可能感兴趣的:(batch)