如何仅在一定时间内循环批处理脚本? [英] How do I loop a batch script only a certain amount of times?

查看:37
本文介绍了如何仅在一定时间内循环批处理脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何只将批处理脚本循环一定次数(x10或类似的次数)? 如果代码是:

How do I loop a batch script only a certain amount of times (x10 or something)? If the code was:

@echo off                                                                     
:loop1                                                                              
Start taskmgr.exe                                                       
Goto loop                                                                         
:loop2                                                                             
Start cmd.exe                                                                 
goto loop2     

如何循环loop1几次并转到loop2?

How can loop loop1 and few times and go to loop2?

任何有用的答案将不胜感激:)

Any helpful answer would be appreciated :)

推荐答案

如果打开命令窗口并键入FOR/?它会为您提供所需的命令.

if you open a command window and type FOR /? it will give you the command you are looking for.

FOR /L %variable IN (start,step,end) DO command [command-parameters]

The set is a sequence of numbers from start to end, by step amount.
So (1,1,5) would generate the sequence 1 2 3 4 5 and (5,-1,1) would
generate the sequence (5 4 3 2 1)

这篇关于如何仅在一定时间内循环批处理脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆