The problem appears to be with certain folder or file names which seem to be expected to appear in the users folder, or in subfolder such as "Documents". These seem to include names like "My Music", "My Pictures", "My Documents", "Local Settings", and some others. (Someone else has reported a similar problem: https://winscp.net/forum/viewtopic.php?t=25666. Perhaps also this: https://winscp.net/forum/viewtopic.php?t=13461.)
Note: These folders are not shown under Windows file explorer (not even as hidden files). However, if I try to create a folder with one of these names, Windows complains that it already exists! So I conjecture these are some kind of hardcoded names known to windows. (Are these folders are a legacy from some earlier version of Windows? I've searched for a Windows fix for this, but I can't find anything useful.)
If I try to use WinSCP, it chokes badly on any of these. For instance, in gui mode, it pops up an "Abort/Retry/Fail" type dialog, and there is no way to skip the bad folder without stopping the upload. I get a similar error in scripting mode, which in the log looks like:
. 2018-03-04 11:48:55.652 File: 'c:\Users\User Name\AppData\Local\Application Data' [2018-02-07T13:14:25.525Z]  * 2018-03-04 11:48:55.653 (EDirectoryNotFoundException) The drive cannot be found . 2018-03-04 11:48:55.653 Asking user: . 2018-03-04 11:48:55.653 File or folder 'c:\Users\User Name\AppData\Local\Application Data' does not exist. ("The drive cannot be found") < 2018-03-04 11:48:55.653 Script: File or folder 'c:\Users\User Name\AppData\Local\Application Data' does not exist. < 2018-03-04 11:48:55.653 Script: The drive cannot be found * 2018-03-04 11:48:55.655 (ESkipFile) File or folder 'c:\Users\User Name\AppData\Local\Application Data' does not exist. * 2018-03-04 11:48:55.655 The drive cannot be found . 2018-03-04 11:48:55.655 Copying finished: Transferred: 1,765,833, Elapsed: 0:00:00, CPS: 15,899,944/s . 2018-03-04 11:48:55.655 Script: Failed . 2018-03-04 11:48:55.655 Script: Exit code: 1 . 2018-03-04 11:48:55.655 Closing connection. . 2018-03-04 11:48:55.655 Sending special code: 12 . 2018-03-04 11:48:55.655 Sent EOF message
I am able to avoid some of these bad folders/files with "option exclude" lines in my script. But for some reason it doesn't work with "Application Data". I'm attaching the full log and script.