I'm using WhatsUpGold to monitor the uptime of services and one of them is a MySql server. Since there's no explicit support for MySql, I'm forced to write a VBS script to do it. Unfortunately, WhatsUpGold doesn't support WScript.Sleep. The alternative that is on their forum is this one but it seems like a dirty hack. Are there any alternatives to the two of these that I can use? I'd really prefer not to have to copy/paste functions around.

5 Answers 5


Ooh, now that is a hacky trick. It'll work though, if the user the app is running as isn't locked down such that it can't use wshell.run. I think I actually like it...

If the app is running on a box that you have admin access to so that you can register a COM DLL, then when I want a sleep in classic ASP code for testing (it is sometimes useful to insert artificial delays) I use a simple free DLL that is unfortunately not longer available from the original source (see here for some discussion). If you want to give it a try I've put a copy in here. To invoke, use something like Dim WaitObj: Set WaitObj = Server.CreateObject ("WaitFor.Comp"): WaitObj.WaitForSeconds 10

No doubt that library is just a wrapper around the sleep API call, so you could make your own if you don't want to trust some random library from some un-vetted 3d party (trusting anonymous code from un-vetted sources is not something I would not recommend, and I count as an un-vetted source). For VB6 the call would be declared as Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long).

First thing I would do at this point though, before trying either of the above, is ask over in StackOverflow to see what other people use for non-busy waits in classic ASP. You might find there is another library out there that is still supported by its creator, or a better technique altogether. As the ping trick is using CreaetObject I suspect that anything usable in a classic ASP context will be usable from your app.


Ugh! I haven't used any of the "WhatsUp" software in years, so I've lost familiarity. A quick review of their forum and a search with my friend Gooogle confirms the ugly hacks you've mentioned.

I'd go for abusing PING like we do in batch files sometimes to get a delay. It's clever, but ugly.

The alternative to being ugly would be to come up with code that doesn't need any "sleep" functionality at all. How are you monitoring MySQL? Are you connecting to it with ODBC and running a query to judge its "aliveness"?


The ping -n X trick is a hack, but not particularly dirty. It is widely known and used in all sorts of Windows batch scripts since the last century ;)


have you tried SleepCMD


Why not just use a a setTimeout method? Look at the following "Hey, Scripting Guy" columns:



You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .