在WinSCP脚本文件中包含共享文件夹的凭据 [英] Include credentials of shared folder in WinSCP script file

查看:1067
本文介绍了在WinSCP脚本文件中包含共享文件夹的凭据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了访问远程共享文件夹,我需要指明用户名和密码。然而,我不知道把它放到我的WinSCP代码中。

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

推荐答案

错误改变目录 lcd 命令。在Windows中,当前工作目录不能是UNC路径( \\网络名称)。

取而代之更改当前工作目录,使用完整路径上传文件:

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\*






但是,如果实际需要凭据访问UNC路径( \\网络名),你必须在运行WinSCP脚本之前进行身份验证。


However if you actually need credentials for accessing the UNC path (the \\networkname), you have to authenticate prior to running the WinSCP script.

批处理文件如下所示:

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

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

net use \\networkname\sharedfolder /delete

积分:如何通过批处理文件创建MAP Drive

您仍然需要使用 put 命令,而不是 lcd 虽然。除非您将UNC路径映射到驱动器号。

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.

这篇关于在WinSCP脚本文件中包含共享文件夹的凭据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆