我正在尝试编写批处理代码以将脚本生成到文件中,以打开与WinSCP的连接;最终命令应类似于:
open sftp://user:[email protected]/
密码包含+
符号,为了使WinSCP能够理解,我必须将其更改为%2B
。
set pw=mypassword+
::echo %pw% return--> mypassword+
set st=%%2B
::echo %st% return--> &2B
call set pw=%%pw:+=%st%%%
::echo %pw% return--> mypassword2B
我找不到最后一次调用以返回%pw%=mypassword%2B
(在%
之前带有2B
的方式)传递给WinSCP脚本的方法。你能帮我吗?还是有其他策略(但始终在批处理文件中)使WinSCP open
命令接受正确的密码?预先感谢。
这似乎起作用:
setlocal enabledelayedexpansion
set pw=!pw:+=%%2B!
注意,您必须删除call
。
基于Batch - replacing with percent symbol。
此外,还有另一种向WinSCP提供密码的方法:
open ftp://[email protected]/ -rawsettings PasswordPlain="mypassword+"