VBScript time out message

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
BlackWisdom
Pro Scripter
Posts: 58
Joined: Thu Oct 16, 2003 12:53 am

VBScript time out message

Post by BlackWisdom » Tue May 10, 2005 12:00 am

I executed a VBscript and after 5 seconds I got a script control message saying the script was taking longer than exprected any way to to disable this..

:o

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue May 10, 2005 7:07 am

From the help file:

"It is possible to set the VBScript code timeout using the VBS_TIMEOUT variable. By default VBScript code will never timeout. To set a timeout, set VBS_TIMEOUT to a value in milliseconds."

E.g:

Let>VBS_TIMEOUT=20000
MJT Net Support
[email protected]

BlackWisdom
Pro Scripter
Posts: 58
Joined: Thu Oct 16, 2003 12:53 am

Still Trying

Post by BlackWisdom » Tue May 10, 2005 2:17 pm

I have placed the Let>VBS_TIMEOUT=20000 statement in about ten diferent places and I still cant stop the timeout notice here is the script:

VBStart
Dim BackupFilesSigDate, filesys, oFolder, srcfolder, tgtfolder, oFile
BackupFilesSigDate = Date -1
srcfolder = "C:\"
tgtfolder = "24HrBackUp\"
Set filesys = CreateObject("Scripting.FileSystemObject")

Set oFolder = filesys.GetFolder(srcfolder)
If Err.Number 0 Then
Wscript.echo "The Source Folder does not exists. Operation aborted."
Set oFolder = Nothing
Set filesys = Nothing
Else
ScanTree(srcfolder)
End If

Set oFile = Nothing
Set oFolder = Nothing
Set filesys = Nothing

Function ScanTree(ByVal sRoot)
Dim oRoot
Dim SubFolder

On Error Resume Next

If Not IsEmpty(sRoot) Then
Set oRoot = filesys.GetFolder(sRoot)
For Each SubFolder In oRoot.SubFolders
If Err.Number 0 Then
Err.Clear
Else
CheckFiles(oRoot)
If Not IsEmpty(SubFolder) Then
'-- use recursion to get the entire tree...
ScanTree SubFolder
End If
End If
Next
End If

On Error Goto 0
End Function

Sub CheckFiles(oFolder)
Dim oFile

On Error Resume Next

For Each oFile In oFolder.Files
If Err.Number 0 Then ' if we got an error, just skip this entry
Err.Clear
ElseIf DateDiff("d", BackupFilesSigDate, oFile.DateCreated) = 0 Then
filesys.copyfile oFile.Path, tgtfolder & "\" & oFile.Name, True
End If
Next

On Error Goto 0
End Sub
VBEND

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue May 10, 2005 6:25 pm

Let>VBS_TIMEOUT=20000

VBStart
....
VBScript stuff
....
VBEnd

VBRun>function,result
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

BlackWisdom
Pro Scripter
Posts: 58
Joined: Thu Oct 16, 2003 12:53 am

Looked at every forum file...

Post by BlackWisdom » Thu May 12, 2005 6:47 am

I reviewed every file on parsing and timeouts - the basic structure of the code is like the example you provided

Let>VBS_TIMEOUT=20000
VBStart

script code -


VBEnd
VBRun>CheckFiles(oFolder) - This is the sub routine near the end of the script

Label>Start
SRT>CloseApp
Press ALT
Press F4
Release ALT
End>CloseApp

thats the basic structure of the script - the exe works perfectly except for the time out problem.

User avatar
Monkster
Junior Coder
Posts: 42
Joined: Fri Oct 04, 2002 9:37 pm
Location: On an Island with Wilson

Post by Monkster » Wed Oct 19, 2005 11:56 am

support wrote:From the help file:

"It is possible to set the VBScript code timeout using the VBS_TIMEOUT variable. By default VBScript code will never timeout. To set a timeout, set VBS_TIMEOUT to a value in milliseconds."

E.g:

Let>VBS_TIMEOUT=20000
Greetings,

I am getting the same error on a similar CPU intensive (100 % CPU usage) script. If I ignore the error, the error message dialog dismisses itself and the script runs through to successful completion.

Here's my script:


Let>VBS_TIMEOUT=400000
VBSTART

Sub GetAllSubFolders(foldername)
On Error Resume Next
Dim f, fc
Set f = fs.GetFolder(foldername)
Set fc = f.SubFolders
For Each f in fc
outf.WriteLine f.Path
GetAllSubFolders foldername & "" & f.name
Next
End Sub

Dim fs, d, foldername
Set fs = CreateObject("Scripting.FileSystemObject")
Set outf = fs.OpenTextFile("C:\~PDrive~.txt", 2, True)

GetAllSubFolders "C:"
outf.Close
Set fs = Nothing
Set outf = Nothing
MsgBox "All done"

VBEND

VBRUN>GetAllSubFolders

(I tried smaller VBS_TIMEOUT values but got the same result.) No big deal, the script still works but I thought you may be interested. :wink:

Thank you for any thoughts!


Edit:
used to read "GetAllSubFolders foldername+"" & f.name"
changed to "GetAllSubFolders foldername & "" & f.name"
works either way, but this is better syntax
Best Wishes,
Monkster

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