If you do need to run the script near midnight, you could use:
exitTime = DateAdd("s", 60, Now())
Do While Now() < exitTime
But: This script seems to peg the CPU usage at 100% until it finishes, which could cause a problem.
An alternative for longer pauses on NT/2000/XP would be to use the "AT" command to schedule the script to run again, and use a command line parameter to indicate that the script should start at a specific point.
Function ScheduleScript(strParam, lSeconds)
'Schedule this script to run with the specified command in a number of seconds
Dim dteRetry, strRetry, strCmd, lRet, Shell
On Error Resume Next
dteRetry = DateAdd("s", lSeconds, Now())
If Hour(dteRetry)=0 Then
strRetry = "12"
ElseIf Hour(dteRetry)>12 Then
strRetry = (Hour(dteRetry)-12)
strRetry = Hour(dteRetry)
strRetry = strRetry & ":" & Right("00" & Minute(dteRetry),2)
If Hour(dteRetry)>=12 Then
strRetry = strRetry & "pm"
strRetry = strRetry & "am"
strCmd = "AT " & strRetry & " /interactive " & Chr(34) & WScript.ScriptFullName & Chr(34)
If Len(strParam) > 0 Then
strCmd = strCmd & " /" & strParam
lRet = -1
Set Shell = WScript.CreateObject("WScript.Shell")
lRet = Shell.Run(strCmd, 0, True)
If Not(lRet=0) Then
ScheduleScript = False
ScheduleScript = True