Problem with VBScript Timeout

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
Okapi
Junior Coder
Posts: 28
Joined: Wed Dec 29, 2010 1:22 am

Problem with VBScript Timeout

Post by Okapi » Fri Jul 15, 2011 8:46 pm

Hi all,

VBS_TIMEOUT doesn't work for me.

When I run this VBScript, it causes a VBScript timeout message after 10 seconds : "Script control : script you are executing is taking longuer then expected ... choose End or Continue". When continuing, the code ends successfully after approximately 35 seconds.

I added Let>VBS_TIMEOUT=50000 before the code to extend the VBScript timeout to 50 seconds, but I still have the same timeout message !

How to eliminate the timeout message ? Thanks.

Code: Select all

Let>VBS_TIMEOUT=50000

VBSTART
' VBScript to get public IP
On Error Resume Next
strComputer = "."
' Main Program
 Getip

 Function Getip
 on error resume next
 const URL = "http://www.domaintools.com/research/my-ip/myip.xml"
  Dim info
  set xmldoc = CreateObject("Microsoft.XMLDOM")
  xmldoc.async=false
  xmldoc.load(URL)
  for each x in xmldoc.documentElement.childNodes
  if x.NodeName = "ip_address" then
  myip = x.text
  end if
  next
  info = info & "IP address : " & myip & vbCRLF
  Getip = info
 end function
VBEND

VBEval>Getip,result
MDL>%result%

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Fri Jul 15, 2011 9:12 pm

I don't know the problem with VBS_TIMEOUT. Your code works fine for me but it returns a result in a few seconds. I'll try it later on my slow home connection and see what happens.

On the other hand if you're just looking for the result of getting an IP address doesn't the script in THIS BLOG POST from Marcus accomplish the same thing?

Okapi
Junior Coder
Posts: 28
Joined: Wed Dec 29, 2010 1:22 am

Post by Okapi » Sat Jul 16, 2011 8:09 pm

Thanks for the script, much fast and easier. I think VBS_TIMEOUT command have an issue to be fixed.

Okapi
Junior Coder
Posts: 28
Joined: Wed Dec 29, 2010 1:22 am

Post by Okapi » Wed Aug 03, 2011 6:02 pm

Simple way to bypass VBS_TIMEOUT message is to copy the VBScript code into a .vbs file with "WriteLn" then "ExecuteFile". And eventually, write results in a file or registry key.

But I hope this issue is to be fixed. Since there's no reference to the compiled script in the timout message box, users may click on End and terminate the script, especially in slow computers, slow Internet connections and blocked scripts by triggered Internet security softwares.

adroege
Automation Wizard
Posts: 438
Joined: Tue Dec 07, 2004 7:39 pm

Post by adroege » Wed Aug 03, 2011 8:17 pm

Code: Select all

Let>VBS_TIMEOUT=70000

VBSTART

 Function taketime
   starttime = Now()
   for x = 1 to 200000000
      y=1
   next
   taketime=datediff("s",starttime,Now())
 end function
VBEND


VBEval>taketime,result
MDL>%result% seconds have elapsed
Interesting.... I see different behavior when I run it from within the editor vs compiled. What do you see?

Okapi
Junior Coder
Posts: 28
Joined: Wed Dec 29, 2010 1:22 am

Post by Okapi » Thu Aug 04, 2011 4:52 am

Thanks for this vbscript that illustrates the vbs timeout message issue. For me it works the same way in editor or compiled. But I've noticed that :

- VBS_TIMEOUT command works correctly and no timeout message after 10 secs in case the vbscript code is executed "outside" VBSTART ... VBEND. And this occurs when using a function to return the result and calling it by VBEval. Example (your code) :

Code: Select all

VBSTART
Function taketime
 starttime = Now()
  for x = 1 to 200000000
   y=1
  next
 taketime=datediff("s",starttime,Now())
end function
VBEND
VBEval>taketime,result
MDL>%result% seconds have elapsed
- And the opposite is true, i.e, VBS_TIMEOUT command doesn't work and a timeout message appears after 10 secs whenever the vbscript code is executed "inside" VBSTART ... VBEND. Some examples :
* Not using a function to return the result :

Code: Select all

VBSTART
starttime = Now()
 for x = 1 to 200000000
  y=1
 next
taketime=datediff("s",starttime,Now())
VBEND
VBEval>taketime,result
MDL>%result% seconds have elapsed
* Call the function that returns the result inside vbscript code :

Code: Select all

VBSTART
Function taketime
 starttime = Now()
  for x = 1 to 200000000
   y=1
  next
 taketime=datediff("s",starttime,Now())
end function
Wscript.Echo taketime & " seconds have elapsed"
VBEND
* Execute the function that returns the result inside vbscript code by adding its name like in my code in first post :

Code: Select all

VBSTART
taketime
Function taketime
 starttime = Now()
  for x = 1 to 200000000
   y=1
  next
 taketime=datediff("s",starttime,Now())
end function
VBEND
VBEval>taketime,result
MDL>%result% seconds have elapsed
So using a function and calling it by VBEval is another way to bypass timeout message.

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts