Without seeing your script it is more or less impossible for anyone to try and troubleshoot it.

Off the top of my head and with no further information my first guess is the hidden window problem. How are you handling that?