Hey guys I’m modifying a script to Count folders on each drive of a system.
the script works fine - but if it tries to Count folders on a drive that does not
exist it generates a path not found error . I tried using on Error Resume Next
- but I dont think Macro Scheduler recognizes it. Here is the script :
VBSTART
Function NumFolders(Path)
set objFS = CreateObject("Scripting.FileSystemObject")
set objFolder = objFS.GetFolder(path)
NumFolders = objFolder.SubFolders.Count
End Function
VBEND
VBEval>NumFolders("c:\"),NumFldrs
WLN>Count.txt,%NumFldrs%
On Error Resume Next
Moderators: JRL, Dorian (MJT support)
On Error Resume Next works just fine. No errors when using a made up drive letter in the function call:
VBSTART
Function NumFolders(Path)
On Error Resume Next
set objFS = CreateObject("Scripting.FileSystemObject")
set objFolder = objFS.GetFolder(path)
NumFolders = objFolder.SubFolders.Count
End Function
VBEND
VBEval>NumFolders("x:\"),NumFldrs
WLN>Count.txt,result,%NumFldrs%
VBSTART
Function NumFolders(Path)
On Error Resume Next
set objFS = CreateObject("Scripting.FileSystemObject")
set objFolder = objFS.GetFolder(path)
NumFolders = objFolder.SubFolders.Count
End Function
VBEND
VBEval>NumFolders("x:\"),NumFldrs
WLN>Count.txt,result,%NumFldrs%
Last edited by support on Tue Jul 12, 2005 5:42 pm, edited 1 time in total.
MJT Net Support
[email protected]
[email protected]
-
- Pro Scripter
- Posts: 58
- Joined: Thu Oct 16, 2003 12:53 am
interesting.. but it works
I pasted your reply into Macro Scheduler - when you run it you get the following value returned instead of the folder count - %NumFldrs%
However if you compile it and run the exe the correct number value for folders is returned.
However if you compile it and run the exe the correct number value for folders is returned.
The last line is wrong. It should be:
WLN>Count.txt,result,%NumFldrs%
I fail to see why results would differ between compiled version and version run natively.
WLN>Count.txt,result,%NumFldrs%
I fail to see why results would differ between compiled version and version run natively.
MJT Net Support
[email protected]
[email protected]