Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
954 views
in Technique[技术] by (71.8m points)

ms access - Getting "Too many parameters for command", when calling WinSCP command-line from VBA

Upload file via FTP from Excel VBA was very helpfull, I'm using the code to synchronize a local folder to my FTP server.

Call Shell( _
     CurrentProject.Path & "WinSCP.com /log=" & CurrentProject.Path & "ftp.log /command " & _
     """open ftp://user:[email protected]/"" " & _
     """synchronize local " & localfolder & " /www/remotefolder/wines -filemask=""*.png"" " & _
     """exit""")

I'm trying to issue an exit command at the end, but the code gives me a

Too many parameters for command 'synchronize'.

The line in the log tells me

synchronize local C:localfolderwines /www/remotefolder/wines -filemask=*.png exit

The exit is in the same line as the synchronize one, when I use the put script this doesn't happen. What can I do to prevent this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You are missing closing quote after the synchronize command. And the quotes around -filemask value have to be doubled. Or actually, you do not need them, as the value does not contain spaces.

This will do:

   """synchronize local " & localfolder & " /www/remotefolder/wines -filemask=*.png""" & _

See https://winscp.net/eng/docs/commandline#syntax


The symbol you have at the beginning of —hostkey and —rawsettings is not a simple hyphen-minus (-), but em-dash ().

Please use hyphen-minus (-) — what is the dash that you find on the standard English [and other] keyboards.

So actually you have the very same problem as in WinSCP forum post you referred to.


Or even easier, have WinSCP GUI generate a script template for you.

Also see FAQ Why are some WinSCP scripting commands specified in a batch file not executed/failing?


Other questions with the same error message, but different problem:


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...