Sleep/Wait
Ernesto Gurgel…
Forums
Hi,
I'm trying to make a script wait a certain amount of time before continuing. The reason is to wait for it to completely send the email with the excel files and then delete the folder containing the files.
Set WScript = CreateObject("WScript.Shell") Dim StartTime, EndTime As Double StartTime = Format$(Now() , "hh:mm:ss") MsgBox "StartTime: "& StartTime
WScript.Sleep 1000
EndTime = Format$(Now() , "hh:mm:ss") MsgBox "EndTime: "& EndTime WScript = Nothing
Hi Ernesto, this is an
Hi Ernesto, this is an interesting question and I came up with a different solution. There is a function called Timer that "Tracks elapsed time" per the Language Browser. I used this in a loop to cause the delay. I first get the current time, I then create a second variable and add 5 seconds to it (or how ever many seconds you want). I think place it in a loop and keep checking the current time, once the current time is greater than the second variable then the loop ends. The problem with this is it won't work around midnight without adding move code to it but if you are running the script during the day you shouldn't have that problem.