1

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

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Qwerty
  • 489
  • 1
  • 4
  • 13
  • `user` command and you'll be prompted for username. `pass` command and you'll be prompted for password. –  Apr 26 '16 at 01:28
  • See http://www.w3.org/Protocols/rfc959/A3_FTP_RFCs.html for a list of commands (under the section FTP commands). –  Apr 26 '16 at 01:34

1 Answers1

0

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:

open ftps://ftpuser:password@hostname/ -explicit -certificate="key"
cd Results
put \\networkname\sharedfolder\folder\*

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:

net use \\networkname\sharedfolder password /user:domain\username /savecred /p:yes

winscp.com /script=... /log=...

net use \\networkname\sharedfolder /delete

Credits: How to create MAP Drive by batch file.

You still need to use the full path with the put command, instead of the lcd though. Unless you map the UNC path to a drive letter.

Community
  • 1
  • 1
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992