' ___________________________________________________________________ ' ' VBScript File: Sleep.vbs ' Author: Frank-Peter Schultze ' ' Updates: http://www.fpschultze.de/modules/smartfaq/faq.php?faqid=73 ' Enhancement Req. ' And Bug Reports: support@fpschultze.de ' ' Built/Tested On: Windows 98 SE, Windows 2000 ' Requirements: OS: Windows 95+, Windows NT4+ ' WSH: 2.0+ ' ' Purpose: Batch file wait. ' ' Syntax: Sleep time-to-sleep-in-seconds ' ' State Changes: Returns exit code 0 ' ' Assumptions And ' Limitations: - ' ' Last Update: 2003-02-11 ' ___________________________________________________________________ ' Option Explicit On Error Resume Next Dim sSecs If Not IsCscript() Then WScript.Echo "Please run this script using CSCRIPT." WScript.Quit(1) End If If ParseCmdLine(sSecs) Then WScript.Sleep CInt(sSecs)*1000 End If WScript.Quit(0) Private Function ParseCmdLine(sSecs) ParseCmdLine = False If WScript.Arguments.Count = 1 Then Select Case WScript.Arguments(0) Case "/?" : ShowUsage(True) Case "-?" : ShowUsage(True) Case "/h" : ShowUsage(True) Case "-h" : ShowUsage(True) Case "h" : ShowUsage(True) Case Else : sSecs = WScript.Arguments(0) ParseCmdLine = True End Select Else ShowUsage(True) End If End Function Private Function IsCscript() IsCscript = False If InStrRev(LCase(WScript.FullName), "cscript.exe", -1) Then IsCscript = True End If End Function Private Sub ShowUsage(bExit) WScript.Echo "Batch file wait." WScript.Echo "" WScript.Echo "Sleep causes the computer to wait for a specified amount of time. Sleep is" WScript.Echo "useful in batch files and may be more convenient to use than the AT command" WScript.Echo "(part of Windows NT 4+) in certain cases." WScript.Echo "" WScript.Echo "Sleep time" WScript.Echo "" WScript.Echo " time The number of seconds to pause." If bExit Then WScript.Quit(1) End If End Sub