#bat等待# #bat退格符#折腾半天。方法不止这些,仅提供我运行成功的
#bat 在同一行列输出# #bat 在同一位置输出#=很好的使用退格符
一:退格符
用IE打开浏览 复制其中的代码:http://bbs.bathome.net/viewthread.php?tid=90&highlight=����
脚本1:光标退格(不删除字符)
注意:下面脚本中 set /p=<nul (如果用记事本打开回事一个黑点,不要替换成其他字符。貌似:ALT 小键盘输入127)
@echo off&for /l %%a in (1 1 18) do echo
set /p= <nul
for /l %%i in (1 1 70) do set /p=^|<nul
for /l %%i in (1 1 70) do set /p=<nul
for /l %%i in (1,1,70) do (
set/p=^><nul
for /l %%a in (1 1 1000) do ver>nul
)
echo&echo&pause
脚本2:设置退格符。看半天没看明白,不过能用。
执行代码后: %bs%等于了退格键。注意定义好变量名,避免重复。
@echo off
call:getbs bs
echo abc%bs%#
pause
:getbs
for /F %%a in ('"prompt $h&for %%b in (1) do rem"')do Set "%~1=%%a"
推荐使用脚本2中的getbs方法获取退格符
二:延迟
脚本3:等待时间,使用VBS的方式。(BAT中最烂的地方就是没有提供sleep)
将下面文件保存成sleep.bat
然后通过 call sleep.bat 1000 的方式来暂停1s
@echo off
set wait_sencents=%1
IF "%wait_sencents%" EQU "". (
set wait_sencents=0
) ELSE (
set /a wait_sencents=%wait_sencents%
echo wscript.sleep %wait_sencents%>sleep.vbs
call wscript sleep.vbs
)
脚本4:批处理等待ping 不存在的IP地址的方式
You can ping a random address and specify the desired timeout:
ping 123.45 . 67.89 - n 1 - w 10000 > nul
And since the address does not exists, it'll wait 10,000 ms (10 seconds) and returns.(注意IP地址要不能存在的,上面语句会wait 10,000 ms)
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).
The > nul part is appended so the ping command doesn't output anything to screen.
rem ===============================================
其他: