Include credentials of shared folder in WinSCP script file

你。 提交于 2019-12-07 07:40:25
Martin Prikryl

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!