如何延迟批处理文件

下载PDF文件下载PDF文件

批处理文件需要延迟操作?在用户表明准备好继续之前,你可以将批处理文件设置为等待,或者在自动处理之前,将批处理文件设置为等待一定时间。你要根据程序需要及系统要求来选择使用哪种方法。

方法 1
方法 1 的 4:

暂停指令

下载PDF文件
  1. How.com.vn 中文: Step 1 用PAUSE指令让程序等待用户响应。...
    PAUSE指令让程序等待用户响应。暂停指令会让计算机处于等待状态,按任意键才能继续进行。如果你希望延迟一个特定时间,参见下述方法之一。[1]
  2. How.com.vn 中文: Step 2 将PAUSE指令设置在你希望它停下来等待的位置。
    到时候系统会提示用户继续进行批处理。
  3. How.com.vn 中文: Step 3 隐藏PAUSE对话框。
    >nul可以加在任意指令的结束位置,将输出结果发送到“虚拟设备”,这样就不会在屏幕上显示。确保不是将 >null加在结束位置;否则会创建一个名为null的新文件,输出结果会出现在新文件里。
    广告
方法 2
方法 2 的 4:

超时指令

下载PDF文件
  1. How.com.vn 中文: Step 1 用TIMEOUT指令让程序等待一个特定时间。
    用户可以跳过这个等待时间,或者添加一个参数,防止用户跳过等待。
    • TIMEOUT指令在旧版系统中无效。如果SLEEP指令无效,尝试被弃用的TIMEOUT指令。
  2. How.com.vn 中文: Step 2 将TIMEOUT指令放置在你希望程序停下来等待的位置。
    添加/t标签,后面紧跟着写秒数。
  3. How.com.vn 中文: Step 3 防止用户跳过终止语句。
    添加/nobreak标签,防止任何输入跳过延迟。
    • 用户还可按Ctrl+C组合键来结束程序进程。
    广告
方法 3
方法 3 的 4:

休眠指令

下载PDF文件
  1. How.com.vn 中文: Step 1 用SLEEP指令让程序等待几秒。
    SLEEP指令已经被弃用;如有可能,用TIMEOUT代替。
  2. How.com.vn 中文: Step 2 将SLEEP指令放置在你希望程序停下来等待的位置。
    添加SLEEP指令执行的秒数。用户不能自行中断SLEEP 指令。
    广告
方法 4
方法 4 的 4:

PING指令

下载PDF文件
  1. How.com.vn 中文: Step 1 用PING指令向另一台计算机发送消息并等待回复,强迫程序等待。
    你必须ping一个无效的IP地址,否则计算机会如实回复,这样延迟时间不够长。不能ping一个无效的主机名,比如madeup.example.com,否则会显示错误消息,而不是延迟。
  2. How.com.vn 中文: Step 2 在你希望延迟的位置插入PING 指令。
    -n 1参数对原始指令添加第二个ping指令。两个ping指令之间的等待时间就是延迟时间,由-w 30000指定。延迟时间必须以毫秒为单位。[2]在结尾输入>nul,向“虚拟设备”发送指令输出。
    广告

关于本How.com.vn

How.com.vn 中文: How.com.vn员工
共同创作者是 :
How.com.vn专职作家
这篇文章由我们训练有素的编辑和研究团队共同创作,他们对文章的准确性和全面性进行了验证。

How.com.vn的内容管理团队会严密监督编辑人员的工作,确保每篇文章都符合我们的高质量标准要求。 这篇文章已经被读过8,558次。
本页面已经被访问过8,558次。

这篇文章对你有帮助吗?

⚠️ Disclaimer:

Content from Wiki How 中文 language website. Text is available under the Creative Commons Attribution-Share Alike License; additional terms may apply.
Wiki How does not encourage the violation of any laws, and cannot be responsible for any violations of such laws, should you link to this domain, or use, reproduce, or republish the information contained herein.

Notices:
  • - A few of these subjects are frequently censored by educational, governmental, corporate, parental and other filtering schemes.
  • - Some articles may contain names, images, artworks or descriptions of events that some cultures restrict access to
  • - Please note: Wiki How does not give you opinion about the law, or advice about medical. If you need specific advice (for example, medical, legal, financial or risk management), please seek a professional who is licensed or knowledgeable in that area.
  • - Readers should not judge the importance of topics based on their coverage on Wiki How, nor think a topic is important just because it is the subject of a Wiki article.

广告