I think maybe I have the counters in the wrong place. It's hard to track when the script is moving to a new user. This is how I am doing the recursive search. Maybe somebody can spot the error with my counter placement. I have some extra echo's for debugging purposes.
''''''''''''''''''''''''''''''''''''''
' Copy of Script found on this site
''''''''''''''''''''''''''''''''''''''
Dim FSO, WSH, objDirectory, objFile, TheFiles
Dim msgcount, sumcount
Set FSO = CreateObject("Scripting.FileSystemObject")
Set WSH = CreateObject("Wscript.Shell")
Set objDirectory = FSO.GetFolder("e:\users")
Set TheFiles = objDirectory.Files
Parentfolder = mid(fso.GetFolder(objDirectory), &_
InstrRev(fso.GetFolder(objDirectory),"\",-1,0)+1, &_
len(fso.GetFolder(objDirectory)) - InstrRev &_
(fso.GetFolder(objDirectory),"\",-1,0)) &_
objextension = "msg"
WorkWithSubFolders objDirectory
'''''''''''''''''''''''''''''''''''''
Function WorkWithSubFolders(objDirectory)
Dim MoreFolders, TempFolder
if (msgcount > 0) Then
sumcount = msgcount
wscript.echo "Count: " & sumcount
end if
msgcount = 0
msgcount = msgcount + ListFilesWithExtension &_(objDirectory)
Set MoreFolders = objDirectory.SubFolders
For Each TempFolder In MoreFolders
wscript.echo "Folder: " & TempFolder
WorkWithSubFolders(TempFolder)
Next
End Function
'''''''''''''''''''''''''''''
Function ListFilesWithExtension(objDirectory)
Dim TheFiles
counter = 0
Set TheFiles = objDirectory.Files
For Each objFile in TheFiles
strExt = fso.GetExtensionName(objFile.Path)
If (strExt = objextension) Then
counter = counter + 1
end if
Next
If (counter > 0 ) Then
ListFilesWithExtension = counter
END IF
End Function