I have a rather unexpected situation here. I have a small application that connects to a WebDAV server (Sharepoint) using the standard WebDAV windows client (WebClient service, part of the "desktop experience" feature), walk through a number of folder and download all PDF files it finds.
The overall process works. However, I'm experiencing a strange issue: when I run the application directly from the server's console or RDP desktop, it runs in about 10 seconds (assuming there is no file to download). When I run the same task from the same user but from a scheduled task, then it takes 5 minutes to complete and yield exactly the same result (files are downloaded if present).
I've added debug to the application to see where the latency happens and the result of this is that the operation of listing the file directory seems to take forever, even if the file filter used causes no file to be returned. The same behavior can be observed when using ProcMon: the latency is within the Win32 calls and ourtside of the application alltogether.
Now, this isn't really critical since the process works, but the more directories the are added the slower it gets and there will be a point where I will have to decrease the frequency at which the script is run so it can actually complete (or change the application so it start to process the directory in parallel).
Would anyone have some kind of explanation why the WebDAV client seems to be several orders of magnitude slower when running from a scheduled task ?
In case it matters, the connection is made with an explicit password each time and it goes over SSL.