
VBScript time out message
Moderators: JRL, Dorian (MJT support)
-
- Pro Scripter
- Posts: 58
- Joined: Thu Oct 16, 2003 12:53 am
VBScript time out message
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..


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
"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]
[email protected]
-
- Pro Scripter
- Posts: 58
- Joined: Thu Oct 16, 2003 12:53 am
Still Trying
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
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
- Bob Hansen
- Automation Wizard
- Posts: 2475
- Joined: Tue Sep 24, 2002 3:47 am
- Location: Salem, New Hampshire, US
- Contact:
-
- Pro Scripter
- Posts: 58
- Joined: Thu Oct 16, 2003 12:53 am
Looked at every forum file...
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.
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.
Greetings,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
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.

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
Monkster