Okay, for all the HTA newbies, the sleep function much be one of the most searched piece of code (the other is how to write a console-like output). Having been a full-fledged vbscript scripter, we don’t think much about the wscript.sleep method until we try to use it on a HTA script.. it does not work!
The Microsoft Scripting center’s solution for this either to use the DHTML method setTimeOut. I don’t really like the solution because it doesn’t really “sleep” the application. Rather, it sets a time delay before the application runs. The sample application is too simplistic. It calls a stub which creates a timer to launch the application at the specified delay time and passes control back to the form.
But what if I have a process that needs to pause a few seconds before it continues? I don’t think that the setTimeOut method can address this well enough.
There are others out there that recommends 3rd party addon, but wanted a more native solution.
After searching for a while, I chanced upon this little workaround in Rube Goldberg Memorial Scripting Page. Its not sometime I really like because it depends on the ping command, but it presents a better workaround than the setTimeout method for what I want to do.
set oShell = CreateObject(“Wscript.Shell”)
cmd = “%COMSPEC% /c ping -n ” & 1 + seconds & ” 127.0.0.1>nul”