[b]方法一:ping[/b]
缺点:时间精度为1秒,不够精确

@echo off
@ping 127.0.0.1 -n 6 > nul
start gdh.txt




[b]方法二:vbs start /wait[/b]


缺点:生成临时文件


优点:时间精度为0.001秒,精度高


@echo off
echo wscript.sleep 5000 > sleep.vbs
start /wait sleep.vbs
start gdh.txt
del /f /s /q sleep.vbs




[b]方法三:vbs cscript[/b]


@echo off
echo wscript.sleep 5000 > sleep.vbs
@cscript sleep.vbs > nul
start gdh.txt
del /f /s /q sleep.vbs




[b]方法四:choice[/b]


优点:时间精确,CPU占用低,是最佳选择


@echo off
choice /t 5 /d y /n > nul
start gdh.txt




[b]方法五:for+set+if,时间精度为0.01秒[/b]


缺点:CPU占用高,语句过长,不常用


@echo off
setlocal enableextensions
echo %time%
call :ProcDelay 500
echo %time%
start gdh.txt
:ProcDelay delayMSec_
setlocal enableextensions
for /f "tokens=1-4 delims=:. " %%h in ("%time%") do set start_=%%h%%i%%j%%k
:_procwaitloop
for /f "tokens=1-4 delims=:. " %%h in ("%time%") do set now_=%%h%%i%%j%%k
set /a diff_=%now_%-%start_%
if %diff_% LSS %1 goto _procwaitloop
endlocal & goto :EOF




[b]我使用的是这个批处理,唯一不好就是有窗口[/b]


@echo off
:: 模拟进度,有剩余时间、已完成进度、进度条的显示
:: code by
color 1f
title.
mode con lines=10
rem   进度条 ▉▉▉▉▉
set work=0
set n=0
set mo=0
set number=0
rem   all是总数
set all=10
set time=%all%
:show

:check
if %number% GTR %mo% set num=%num%▉&set /a mo=%mo%+1&goto check

:2

cls
echo   进度: %n% / %all%           ★程序正在启动请稍等★           剩余时间:%time%秒
echo.
echo.
echo                                   完成 %work% %%%
echo.
if not "%num%"=="" echo       %num%
if not "%num%"=="" echo       %num%

if %work%==100 goto end

ping 127.1 -n 2 >nul
set /a n=%n%+1
set /a time=%all%-%n%
set /a work=(%n%)*100/(%all%)
set /a number=%work%/3
set /a number=%number%+1
goto show
endlocal

:end
@echo off
start C:\Progra~1\tools\xsdy\1.exe
exit