Basically I am having to write a "work-around" script for some Software an Insurance House has provided us with that is playing up. So while they work on a proper fix I have thought of a work around to the problem.
Basically what is happening is their print monitor is crashing, the best way to solve this is to close it and restart the program which then starts pushing the documents through. This print monitor stores the documents in the Doc & Settings/App Data/%username%/....... area.
I am writing a script so that when a file in that folder is over 2 minutes old it automatically kills the print processor and then restarts it. This is to make sure that the document does get forced through.
The problem I have is no matter what I do the attached code counts the amount of files in the folder even if they were JUST created, and not over 2 minutes old. I think I need a set of far more experienced eyes to see if I am doing anything wrong, I am very new to this so I may have mis-understood something or overlooked something simple for that I apologise if so.
Set colFiles = oFolder.Files
nFiles = colFiles.Count
For Each oFile In colFiles
If DateDiff("s", oFile.DateCreated, Now()) >= 120000 Then '-- ensure file is at least 2 minutes old
nFiles = colFiles.Count - 1 '-- to avoid COUNTING NEW FILES