WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Functions

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Winbatch hangs on TimeDelay


Question:

Can anyone explain why winbatch sometimes, not always, hangs during a TimeDelay() command in a script. It doesn't make any sense but it does hang indefinitely and when I terminate the script it shows that the script is on a line with TimeDelay(2) for example. Here's the part of code that I'm referring to:
SendKeysTo(cmwinid,"{ENTER}")
TimeDelay(2) <-----------hangs here
If varWindows==`xp` Then SendKeysTo(cmwinid,"{TAB 2}")

Answer:

Depends. When you hace a timedelay in a loop, and then cancel a script while it is in the loop...well 99.999999% of time time, the loop is sitting at the timedelay, even when the real problem is a failure to break out of the loop for some other reason. Adding a DebugTrace function to make a debug trace log might lend some insight to this.

If, on the other hand, something is changing the system time, the TimeDelay function can get confused.

User Reply:

Well this is not in a loop so we can rule that cause out. And we are changing the time zone and synchronizing with internet time server just before that so that probably is the problem.

Answer:

Changing the timezone and time is probably what is affecting the TimeDelay function. Basically a TimeDelay is converted to a TimeWait based on the current system clock. If the clock changes, then the TimeDelay can also be affected.

I recommend trying to pass the TimeDelay a negative number. Specifying negative numbers uses a different, more accurate algorithm. Not sure this resolve the problem.

If that doesn't work, we may need to find a workaround (like spliting the timezome code into a seperate script).


Article ID:   W16982
File Created: 2007:07:03:14:27:28
Last Updated: 2007:07:03:14:27:28