In order to access a remote shared folder, I need to indicate the username and password. However, I have no idea where to put it in my WinSCP code.
open ftps://ftpuser:password@hostname/ -explicit -certificate="key"
cd Results
lcd \\networkname\sharedfolder\folder\
put *
This produces an error which is:
Error changing directory to '...'.
Any idea? Thanks
The error "Error changing directory", which you are getting is most probably caused by the
lcd
command. In Windows, the current working directory cannot be an UNC path (the\\networkname
).Instead of changing the current working directory, upload the file using a full path:
However if you actually need credentials for accessing the UNC path (the
\\networkname
), you have to authenticate prior to running the WinSCP script.The batch file will be like:
Credits: How to create MAP Drive by batch file.
You still need to use the full path with the
put
command, instead of thelcd
though. Unless you map the UNC path to a drive letter.