方法一:
最简单的方法利用WSH - Windows Script Host
WScript.Sleep 10
方法二:使用ping命令,每个ping命令延迟4秒钟
ping localhost > nul
ping localhost 1>nul 2>nul
ping localhost 1> nul 2>&1
方法三:使用debug命令
ASCII汇编代码,延迟精度为0.001秒,适用平台为MS-DOS/Win9x/WinNT。
德国人Herbert Kleebauer给出了一个通用方案,通过ASCII汇编器间接产生一个sleep.exe程序来实现延迟,这个程序分为DOS和Win两个模块,分别调用DOS系统中断服务和WindowsAPI。
CODE: [Copy to clipboard]
--------------------------------------------------------------------------------
:: Sleep.bat - Sleep/Delay/Wait n seconds
:: Herbert Kleebauer(Germany) - 2005/05/29
:: Modified by Will Sort - 2005/06/02, 07-25
@echo off
echo q | debug>nul
echo
echo 0DxFP,0Xx.t0P,=XtGsB4o@$?PIyU WwX0GwUY Wv;ovBX2Gv0ExGIuht6>>sleep.com
echo
echo
echo
echo
echo
echo
echo dsmSQswDOR[BQAQ?LUA?_L_oUNUScLOOuLOODUO?UOE@OwH?UOQ?DJTSDM>>sleep.com
echo
echo @dmTkRQSoddTT~?K?OCOQp?o??Gds?wOw?PGAtaCHQvNntQv_w?A?it\EH>>sleep.com
echo
echo Q??PGT~B??OC~?ipO?T?~U?p~cUo0x>>sleep.com
sleep.com>sleep.exe
echo wait %1 seconds:
sleep.exe %1000
del sleep.com
del sleep.exe
方法四:使用Windows API,
需要注意的是VBS不能调用Windows API,需要用Microsoft Visual Studio或.Net编码调用Windows API
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Command1_Click()
MsgBox "begin"
Sleep 10000
MsgBox "end"
End Sub
方法五:使用java, Thread.sleep(10)
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
方法六: Windows 2003 自带sleep 程序
阅读(15993) | 评论(1) | 转发(0) |