I experience the same //PWD issue with WinSCP 5.5.3 (build 4214), here is my log when I try to change the current directory to "yann" and delete the "about.html" file in this directory just after the session opening :
> 2016-10-27 17:19:56.923 Script: cd yann
. 2016-10-27 17:19:56.923 Cached directory change via "yann" to "//PWD".
. 2016-10-27 17:19:56.923 Getting current directory name.
< 2016-10-27 17:19:56.923 Script: //PWD
> 2016-10-27 17:19:56.924 Script: rm about.html
. 2016-10-27 17:19:56.924 Listing file "about.html".
. 2016-10-27 17:19:56.924 Retrieving directory listing...
> 2016-10-27 17:19:56.924 CWD /PWD/
< 2016-10-27 17:19:56.939 550 /PWD/: No such file or directory
. 2016-10-27 17:19:56.939 Could not retrieve directory listing
. 2016-10-27 17:19:56.939 LIST with -a failed, walling back to pure LIST
. 2016-10-27 17:19:56.939 Retrieving directory listing...
> 2016-10-27 17:19:56.939 CWD /PWD/
< 2016-10-27 17:19:56.950 550 /PWD/: No such file or directory
. 2016-10-27 17:19:56.950 Could not retrieve directory listing
< 2016-10-27 17:19:56.951 Script: Can't get attributes of file 'about.html'.
< 2016-10-27 17:19:56.951 Script: Could not retrieve directory listing
Obviously, the problem is with the cached directory change via "yann" to "//PWD"
I can't explain the problem, an I'd like to know if there is an option to disable caching while scripting (I use winscp.com). I see the /rawsetting parameter, but in the winscp.ini file, the "CacheDirectories" and "CacheDirectoryChanges" are [Sessions/xxxx] parameters, and not [Configuration/xxx] parameters.
So the caching seems impossible to disable...the best way would be to delete the cache from the hard drive before running my script, but I can't figure out where it is stored ? I'll investigate to find and delete the cache, but in the next release of WinSCP, could you add a script command to clear the cached directories ? It could also be a new option parameter (option cachedir on|off) for instance.