写了一个监控通讯的脚本 然后终结了一些方法
BAT脚本中的等待Sleep或者Wait
因为没有原生的命令一般用以下方法实现
ping 123.45.67.1 -n 1 -w 10000 > nul
ping一个不存在的地址
The -w 10000 part specifies the desired timeout in milliseconds. 就是等待时间
The -n 1 part tells ping that it should only tries once (normally it'd try 4 times). 尝试ping的次数
The > nul part is appended so the ping command doesn't output anything to screen.不打印在屏幕上
然后清空屏幕的命令
cls
循环用goto加标志位例如 :ks
例子如下:
@echo off
:ks
//TODO
ping 123.45.67.1 -n 1 -w 10000 > nul
cls
goto ks
这样就是一个10秒循环执行并刷新屏幕的脚本模板
网友评论